Difference between revisions of "LibreNMS - snmp extend nginx"
From wiki.1001solutions.net
(6 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
= NginX LibreNMS script = | = NginX LibreNMS script = | ||
− | Get the script: | + | Get the script and make it executable: |
<nowiki> | <nowiki> | ||
− | wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/nginx -O /etc/snmp/nginx</nowiki> | + | wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/nginx -O /etc/snmp/nginx && chmod +x /etc/snmp/nginx</nowiki> |
− | + | Adapt the url in the script to your configuration, eg: | |
− | + | <nowiki> | |
− | + | data = urlopen('http://127.0.0.1/nginx_status').read()</nowiki> | |
− | + | '''Be careful, 'localhost' seems bugging, use 127.0.0.1 instead...''' | |
Line 32: | Line 32: | ||
} | } | ||
}</nowiki> | }</nowiki> | ||
+ | |||
+ | |||
+ | |||
+ | = sudo Configuration = | ||
+ | |||
+ | Adapt your ''/etc/sudoers'' with: | ||
+ | <nowiki> | ||
+ | Debian-snmp ALL=(ALL) NOPASSWD: /etc/snmp/nginx</nowiki> | ||
+ | |||
+ | |||
+ | |||
+ | = SNMP Configuration = | ||
+ | |||
+ | Adapt your ''/etc/snmp/snmpd.conf'' with: | ||
+ | <nowiki> | ||
+ | extend nginx /usr/bin/sudo /etc/snmp/nginx</nowiki> | ||
+ | Restart the service. | ||
+ | |||
+ | |||
+ | |||
+ | = Check Command = | ||
+ | |||
+ | Adapt the user and path to your configuration: | ||
+ | <nowiki> | ||
+ | sudo -u Debian-snmp /etc/snmp/nginx</nowiki> | ||
Latest revision as of 09:18, 3 May 2020
Contents
NginX LibreNMS script
Get the script and make it executable:
wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/nginx -O /etc/snmp/nginx && chmod +x /etc/snmp/nginx
Adapt the url in the script to your configuration, eg:
data = urlopen('http://127.0.0.1/nginx_status').read()
Be careful, 'localhost' seems bugging, use 127.0.0.1 instead...
vHOST
Adapt your config with:
server { listen 127.0.0.1:80; server_name 127.0.0.1; location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; allow ::1; deny all; } }
sudo Configuration
Adapt your /etc/sudoers with:
Debian-snmp ALL=(ALL) NOPASSWD: /etc/snmp/nginx
SNMP Configuration
Adapt your /etc/snmp/snmpd.conf with:
extend nginx /usr/bin/sudo /etc/snmp/nginx
Restart the service.
Check Command
Adapt the user and path to your configuration:
sudo -u Debian-snmp /etc/snmp/nginx
Sources