Configure a new nginx server listening on an alternate port (61709 in this example). This allows access to this information to be controlled.
server {
listen 61709;
location / {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
Reload Nginx
/etc/init.d/nginx reload
Add the following to the end of /etc/zabbix/zabbix_agentd.conf
#Nginx Keys
# NginX Keys
UserParameter=nginx.active[*],wget -O- -q $1:$2 | awk ‘/^Active/ {print $NF}’
UserParameter=nginx.reading[*],wget -O- -q $1:$2 | awk ‘/Reading/ {print $$2}’
UserParameter=nginx.writing[*],wget -O- -q $1:$2 | awk ‘/Writing/ {print $$4}’
UserParameter=nginx.waiting[*],wget -O- -q $1:$2 | awk ‘/Waiting/ {print $$6}’
UserParameter=nginx.accepted[*],wget -O- -q $1:$2 | awk ‘/^[ \t]+[0-9]+[ \t]+[0-9]+[ \t]+[0-9]+/ {print $$1}’
UserParameter=nginx.handled[*],wget -O- -q $1:$2 | awk ‘/^[ \t]+[0-9]+[ \t]+[0-9]+[ \t]+[0-9]+/ {print $$2}’
UserParameter=nginx.requests[*],wget -O- -q $1:$2 | awk ‘/^[ \t]+[0-9]+[ \t]+[0-9]+[ \t]+[0-9]+/ {print $$3}’
Restart the Zabbix agent
/etc/init.d/zabbix-agent restart
To use these UserParameters, set the host (localhost) and port (61709) in the key
nginx.active[localhost,61709]