标签:cat html zabbix 20px 作用 keep awk 客户端 配置
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
root "/var/www/html";
location / {
index index.html index.htm index.php l.php;
autoindex off;
}
location /status {
stub_status on;
} #开启nginx的stub_staus模块,这个模块主要作用是提供对基本信息状态的访问。
vim /etc/zabbix/shell/nginx_monitor.sh #!/bin/bash HOST="127.0.0.1" function exist { /sbin/pidof nginx | wc -l } function active { /usr/bin/curl "http://$HOST/status" 2>/dev/null | egrep "Active" | awk ‘{print $NF}‘ } function reading { /usr/bin/curl "http://$HOST/status/" 2>/dev/null| grep ‘Reading‘ | awk ‘{print $2}‘ } function writing { /usr/bin/curl "http://$HOST/status/" 2>/dev/null| grep ‘Writing‘ | awk ‘{print $4}‘ } function waiting { /usr/bin/curl "http://$HOST/status/" 2>/dev/null| grep ‘Waiting‘ | awk ‘{print $6}‘ } function accepts { /usr/bin/curl "http://$HOST/status/" 2>/dev/null| awk NR==3 | awk ‘{print $1}‘ } function handled { /usr/bin/curl "http://$HOST/status/" 2>/dev/null| awk NR==3 | awk ‘{print $2}‘ } function requests { /usr/bin/curl "http://$HOST/status/" 2>/dev/null| awk NR==3 | awk ‘{print $3}‘ } $1
[root@zabbix_agent zabbix_agentd.d]# cat zbx_nginx.conf UserParameter=nginx_status[*],/bin/bash /etc/zabbix/shell/nginx_monitor.sh $1
[root@zabbix_server ~]# zabbix_get -s 192.168.1.130 -k nginx_status[active] 1 [root@zabbix_server ~]# zabbix_get -s 192.168.1.130 -k nginx_status[requests] 197 测试OK
Active:对后端发起的活动连接数;
accepts:nginx 总共处理的连接;
handled:成功创建的握手;
requests:总共处理的2请求。
Reading:读取客户端的连接数
Writing: 响应数据到客户端的数量
Waiting: 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.
标签:cat html zabbix 20px 作用 keep awk 客户端 配置
原文地址:https://www.cnblogs.com/psc0218/p/12996762.html