标签:deny template stat 重启 pidof 监控nginx root 添加 Stub
zabbix需要监控nginx,则nginx需要配置nginx_statusfunction ping {
/sbin/pidof nginx | wc -l
}
function active {
/usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep ‘Active‘ | awk ‘{print $NF}‘
}
function reading {
/usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep ‘Reading‘ | awk ‘{print $2}‘
}
function writing {
/usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep ‘Writing‘ | awk ‘{print $4}‘
}
function waiting {
/usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep ‘Waiting‘ | awk ‘{print $6}‘
}
function accepts {
/usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| awk NR==3 | awk ‘{print $1}‘
}
function handled {
/usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| awk NR==3 | awk ‘{print $2}‘
}
function requests {
/usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| awk NR==3 | awk ‘{print $3}‘
}
$1
将自定义的UserParameter加入zabbix_agentd.conf配置文件,然后重启agentd
vi /etc/zabbix/zabbix_agentd.conf
UserParameter=nginx.status[*],/bin/bash /etc/zabbix/scripts/nginx_status.sh $1
重启agentd
/etc/init.d/zabbix-agent restart
模板附件下载:zabbix_monitor_nginx_template_ttlsa_com
http://www.ttlsa.com/wp-content/uploads/2015/10/zabbix_monitor_nginx_template_ttlsa_com.zip
导入模板:配置、模板、导入模板
给该主机添加nginx的监控项:
完成,查看图形:
标签:deny template stat 重启 pidof 监控nginx root 添加 Stub
原文地址:http://blog.51cto.com/10158955/2141367