作好本地DNS解析nginx
一、開啓Nginx狀態模塊
vim
# /application/nginx/sbin/nginx -Vbash
configure arguments: --user=nginx --group=nginx --prefix=/application/nginx-1.6.3/ --with-http_stub_status_module --with-http_ssl_module --with-http_spdy_module --with-pcreapp
二、查看curl
Active connections: 2url
server accepts handled requestsspa
50 50 1055server
Reading: 0 Writing: 1 Waiting: 1blog
三、修改zabbix_agent.conf的配置文件
vim /application/zabbix/etc/zabbix_agentd.conf
UnsafeUserParameters=1
Include=/application/zabbix/etc/zabbix_agentd.conf.d/*.conf
四、準備腳本
#!/bin/bash
HOST='status.zabbix1.org'
function ping {
/sbin/pidof nginx | wc -l
}
function active {
/usr/bin/curl "$HOST" 2>/dev/null | grep 'Active' | awk '{print $NF}'
}
function reading {
/usr/bin/curl "$HOST" 2>/dev/null | grep 'Reading' | awk '{print $2}'
}
function writing {
/usr/bin/curl "$HOST" 2>/dev/null | grep 'Writing' | awk '{print $4}'
}
function waiting {
/usr/bin/curl "$HOST" 2>/dev/null | grep 'Waiting' | awk '{print $6}'
}
function accepts {
/usr/bin/curl "$HOST" 2>/dev/null | awk NR==3 | awk '{print $1}'
}
function handled {
/usr/bin/curl "$HOST" 2>/dev/null | awk NR==3 | awk '{print $2}'
}
function requests {
/usr/bin/curl "$HOST" 2>/dev/null | awk NR==3 | awk '{print $3}'
}
$1
五、添加nginx自定義Key的配置文件
vim /application/zabbix/etc/zabbix_agentd.conf.d/nginx_status.conf
UserParameter=nginx.status[*],/application/zabbix/scripts/nginx_status.sh "$1"
六、在Web管理界面添加監控項
七、添加監控圖形
八、查看圖形