添加查看状态页面功能
[root@master ~]# vim /usr/local/nginx/conf/nginx.conf
server {
listen 81;
server_name localhost;
location = /status{
stub_status;
}
[root@master ~]# curl -s http://192.168.160.132:81/status
Active connections: 1
server accepts handled requests
67 67 66
Reading: 0 Writing: 1 Waiting: 0
编写nginx状态页面脚本
[root@master ~]# mkdir -p /scripts/ && cd /scripts/
[root@master scripts]# vim check_nginx.sh
#!/bin/bash
status=$(curl -s http://192.168.160.132:81/status |awk 'NR==4{print $4}')
if [ $status -ge 1 ];then
echo "1"
else
echo "0"
fi
//开启自定义监控并添加指标
[root@master scripts]# vim /usr/local/etc/zabbix_agentd.conf
UnsafeUserParameters=1
UserParameter=check_nginx,/scripts/check_nginx.sh
//重启zabbix
[root@master scripts]# pkill zabbix
[root@master scripts]# zabbix_server
[root@master scripts]# zabbix_agentd
//测试是否能获取客户端的指标
[root@master scripts]# zabbix_get -s 192.168.160.132 -k check_nginx
1
添加主机
手动加监控项
创建触发器
报警: