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