zabbix自定义监控nginx状态页面

发布时间:2022-07-01 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了zabbix自定义监控nginx状态页面脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

zabbix自定义监控nginx状态页面

确保nginx状态界面打开
[root@nginx ~]# nginx -V
nginx version: nginx/1.20.1
built by gcc 8.2.1 20180905 (red hat 8.2.1-3) (GCC) 
built wITh OPEnSSL 1.1.1 FIPS  11 Sep 2018
TLS SNI support enabled
configure arguments: --PRefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-LOG-path=/VAR/log/nginx/access.log --error-log-path=/var/log/nginx/error.log

zabbix自定义监控nginx状态页面

 

这里选择监控Waiting的值
[root@localhost ~]# curl -s 192.168.145.175/status |awk 'NR==4'|awk -F: {'print $4'}
 0 

[root@nginx ~]# yum -y install gcc gcc-c++ bzip2 pcre* make wget
[root@nginx ~]# wget https://cdn.zabbix.COM/zabbix/sources/stable/5.4/zabbix-5.4.6.tar.gz
[root@nginx ~]# ls
公共  视频  文档  音乐  anaconda-ks.CFg       zabbix-5.4.6.tar.gz
模板  图片  下载  桌面  initial-SETUP-ks.cfg  zabbix-5.4.6.tar.gz.1
[root@nginx ~]# tar xf zabbix-5.4.6.tar.gz 
[root@nginx ~]# tar xf zabbix-5.4.6.tar.gz 
[root@nginx ~]# useradd -r -M -s /sbin/nologin zabbix
[root@nginx ~]# chown zabbix.zabbix zabbix-5.4.6
[root@nginx ~]# cd zabbix-5.4.6/
[root@nginx zabbix-5.4.6]# ./configure --enable-agent
[root@nginx zabbix-5.4.6]# make install

Server=192.168.145.170      修改成zabbix服务端IP
ServerActive=192.168.145.170        修改成zabbix服务端IP
Hostname=nginx      主机名
UnsafeUserParameters=1
UserParameter=status,/scripts/status.sh         添加这行指明脚本位置 

编写监控脚本
[root@nginx ~]# mkdir /scripts
[root@nginx ~]# cd /scripts/
[root@nginx scripts]# vim status.sh
[root@nginx scripts]# cat status.sh 
#!/bin/bash

status=$(curl -s 192.168.145.175/status |awk 'NR==4'|awk -F: {'print $4'})

if [ $status -ge 1 ];then
        echo "1"
else
        echo "0"
fi
[root@nginx scripts]# chmod +x status.sh 
[root@nginx scripts]# ls
status.sh

开启服务
[root@nginx ~]# zabbix_agentd 
[root@nginx ~]# ss -antl
State    recv-Q     Send-Q          Local Address:Port          Peer Address:Port    
LISTEN   0          32              192.168.122.1:53                 0.0.0.0:*       
LISTEN   0          128                   0.0.0.0:22                 0.0.0.0:*       
LISTEN   0          5                   127.0.0.1:631                0.0.0.0:*       
LISTEN   0          128                   0.0.0.0:10050              0.0.0.0:*       
LISTEN   0          128                   0.0.0.0:111                0.0.0.0:*       
LISTEN   0          128                   0.0.0.0:80                 0.0.0.0:*       
LISTEN   0          128                      [::]:22                    [::]:*       
LISTEN   0          5                       [::1]:631                   [::]:*       
LISTEN   0          128                      [::]:111                   [::]:*      


[root@localhost ~]# zabbix_get -s 192.168.145.175 -k status
0
[root@localhost ~]# zabbix_get -s 192.168.145.175 -k status
1

zabbix自定义监控nginx状态页面

 

zabbix自定义监控nginx状态页面

 

脚本宝典总结

以上是脚本宝典为你收集整理的zabbix自定义监控nginx状态页面全部内容,希望文章能够帮你解决zabbix自定义监控nginx状态页面所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。