Edit nginx.conf File
Add content inside the server
Location/nginx-status {
Stub_status on;
Access_log off;
}
2.zabbix AGENTD Client Configuration
Edit/usr/local/zabbix/etc/zabbix_agentd.conf
Add the following at the end of the file
Unsafeuserparameters=1
Userparameter=nginx.accepts,/usr/local/zabbix/scripts/nginx_status.sh accepts
Userparameter=nginx.handled,/usr/local/zabbix/scripts/nginx_status.sh handled
userparameter=nginx.requests,/usr/local/zabbix/scripts/nginx_status.sh Requests
Userparameter=nginx.connections.active,/usr/local/zabbix/scripts/nginx_status.sh Active
userparameter=nginx.connections.reading,/usr/local/zabbix/scripts/nginx_status.sh Reading
userparameter=nginx.connections.writing,/usr/local/zabbix/scripts/nginx_status.sh Writing
Userparameter=nginx.connections.waiting,/usr/local/zabbix/scripts/nginx_status.sh Waiting
3. Edit the nginx_status.sh file
cat/usr/local/zabbix/scripts/nginx_status.sh
#!/bin/bash
host=127.0.0.1 (If you write a domain name under each domain name)
Term=$1
# Functions to return nginx stats
Function Active {
/usr/bin/curl "/http $HOST/nginx-status" 2>/dev/null | grep ' Active ' | awk ' {print $NF} '
}
function reading {
/usr/bin/curl "/http $HOST/nginx-status" 2>/dev/null | grep ' Reading ' | awk ' {print $} '
}
function writing {
/usr/bin/curl "/http $HOST/nginx-status" 2>/dev/null | grep ' Writing ' | awk ' {print $4} '
}
function waiting {
/usr/bin/curl "/http $HOST/nginx-status" 2>/dev/null | grep ' Waiting ' | awk ' {print $6} '
}
function accepts {
/usr/bin/curl "/http $HOST: $PORT/nginx-status" 2>/dev/null | awk nr==3 | awk ' {print '} '
}
function handled {
/usr/bin/curl "/http $HOST/nginx-status" 2>/dev/null | awk nr==3 | awk ' {print $} '
}
function requests {
/usr/bin/curl "/http $HOST/nginx-status" 2>/dev/null | awk nr==3 | awk ' {print $} '
}
$TERM
chmod +x/usr/local/zabbix/scripts/nginx_status.sh
4. Restart Zabbix_agentd
Service Zabbix_agentd Restart
5.zabbixweb Control-Side Import Template
6.zabbix Monitoring Client Add Nginx module
This article is from the "System website Operations" blog, please be sure to keep this source http://cgc243652136qq.blog.51cto.com/3989433/1828323
Zabbix monitoring Nginx