nginx开启status
./configure --with-http_stub_status_module nginx.conf
location /statusx35 {
stub_status on;
}
http://127.0.0.1/statusx35
Active connections:
server accepts handled requests Reading: Writing: Waiting:
nginx status状态值详解
Active connections: 活跃的连接次数
server accepts handled requests: 一共处理的连接次数,成功创建的握手次数,一共处理的请求次数
Reading: 读取客户端的连接数
Writing: 响应数据到客户端的数量
Waiting: 开启 keep-alive 的情况下,这个值等于 active C (reading+writing),意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接。
定义zabbix监控item key
vim etc/zabbix_agentd.conf.d/userparameter_nginx.conf
UserParameter=nginx.status[*],/storage/server/zabbix-agent/scripts/nginx_status.sh $
nginx_status.sh
#!/bin/bash
# // pdd HOST=127.0.0.1
PORT=
URI="/statusx35" case "$1" in
Active_connections)
curl -s -m --no-keepalive "http://${HOST}:${PORT}${URI}" | awk 'NR==1 {print $3}'
;;
server_accepts)
curl -s -m --no-keepalive "http://${HOST}:${PORT}${URI}" | awk 'NR==3 {print $1}'
;;
server_handled)
curl -s -m --no-keepalive "http://${HOST}:${PORT}${URI}" | awk 'NR==3 {print $2}'
;;
server_requests)
curl -s -m --no-keepalive "http://${HOST}:${PORT}${URI}" | awk 'NR==3 {print $3}'
;;
Reading)
curl -s -m --no-keepalive "http://${HOST}:${PORT}${URI}" | awk 'NR==4 {print $2}'
;;
Writing)
curl -s -m --no-keepalive "http://${HOST}:${PORT}${URI}" | awk 'NR==4 {print $4}'
;;
Waiting)
curl -s -m --no-keepalive "http://${HOST}:${PORT}${URI}" | awk 'NR==4 {print $6}'
;;
*)
echo "Usage: $0 Active_connections|server_accepts|server_handled|server_requests|Reading|Writing|Waiting"
esac
重启zabbix_agentd使监控key生效
客户端测试
服务器端 # 页面监控主机添加对应的application items
创建Graphs(nginx status)
zabbix后台 Configuration->Hosts->被监控的主机name->Graphs
查看graph(nginx status)
zabbix后台 Monitoring->Graphs->对应的graph