zabbix监控nginx的pv:
bash
pv)
cat /var/log/nginx/access.log|awk '{print $1}'|wc -l
;;
zabbix-get验证:
bash
[root@bogon ~]# zabbix_get -s 192.168.253.231 -k pv_uv[pv]
100
zabbix监控nginx的uv
bash
uv)
cat /var/log/nginx/access.log|awk '{print $1}'|uniq -c | wc -l
;;
zabbix-get验证:
bash
[root@bogon ~]# zabbix_get -s 192.168.253.231 -k pv_uv[uv]
2
zabbix监控nginx的状态码:
bash
status_code)
cat /var/log/nginx/access.log|awk '{print $9}'|uniq -c|tail -n 1|awk '{print $2}'
;;
zabbix-get验证:
bash
[root@bogon ~]# zabbix_get -s 192.168.253.231 -k pv_uv[status_code]
200
整个nginx监控脚本:
bash
#!/bin/bash
case $1 in
pv)
cat /var/log/nginx/access.log|awk '{print $1}'|wc -l
;;
uv)
cat /var/log/nginx/access.log|awk '{print $1}'|uniq -c | wc -l
;;
status_code)
cat /var/log/nginx/access.log|awk '{print $9}'|uniq -c|tail -n 1|awk '{print $2}'
;;
esac
pv数据如下:
uv数据如下:
status_code数据如下:
粉丝福利