Zabbix监控Nginx的status
部署Zabbix监控Nginx的status
环境说明:
主机名 | IP | 服务 | 系统 |
---|
zabbix | 192.168.188.130 | zabbix | centos8 | nginx | 192.168.188.128 | nginx zabbix_agentd | centos8 |
部署zabbix不作演示,请参考此篇博客👉部署zabbix监控服务
nginx开启状态页面
nginx能开启状态页面的前提是安装了这个模块,你可以nginx -V查看一下编译参数里有无--with-http_stub_status_module
[root@nginx ~]
......
location = /status {
stub_status;
allow 127.0.0.1;
allow 192.168.188.1;
deny all;
}
.......
[root@nginx ~]
验证是否能访问,不能访问则无法监控状态
[root@nginx ~]
Active connections: 1
server accepts handled requests
1 1 1
Reading: 0 Writing: 1 Waiting: 0
去浏览器验证真实本机是否能访问

在nginx服务器安装zabbix_agentd并配置监控脚本
安装zabbix_agentd
[root@nginx ~]
[root@nginx ~]
[root@nginx ~]
[root@nginx src]
[root@nginx src]
[root@nginx src]
[root@nginx zabbix-6.2.3]
......
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
[root@nginx zabbix-6.2.3]
[root@nginx zabbix-6.2.3]
[root@nginx etc]
zabbix_agentd.conf zabbix_agentd.conf.d
[root@nginx etc]
.......................
Server=192.168.188.130
.......................
ServerActive=192.168.188.130
.......................
Hostname=nginx
.......................
[root@nginx etc]
[root@nginx etc]
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
编写并配置监控脚本
[root@nginx ~]
[root@nginx ~]
[root@nginx scripts]
case $1 in
Reading)
curl -s 127.0.0.1/status |awk "NR==4{print\$2}"
;;
Writing)
curl -s 127.0.0.1/status |awk "NR==4{print\$4}"
;;
Waiting)
curl -s 127.0.0.1/status |awk "NR==4{print\$6}"
;;
*)
exit
;;
esac
[root@nginx scripts]
[root@nginx scripts]
.............
UnsafeUserParameters=1
UserParameter=nginx_status[*],/bin/bash /scripts/nginx_status.sh $1
[root@nginx scripts]
[root@nginx scripts]
[root@zabbix-server ~]
0
在zabbix的Web界面配置监控nginx
添加主机
 添加监控项
监控Reading
 监控Writing
 监控Waiting
  查看是否有监控返回的值,有值则说明监控成功了

  添加触发器 在企业中要视具体服务器情况而作配置
|