操作版本:
zabbix-server:4.0.5
zabbix-agent:4.0.5
一、修改nginx配置文件,内容示例如下
如果是在生产环境上,有定义根重定向的或没有定义根重定向,都可以用以下 nginx 的配置…
server {
listen 80;
server_name 192.168.0.12;
location ^/
{
rewrite / /status permanent;
}
location /status {
stub_status on;
allow 127.0.0.1;
access_log off;
}
}
二、 Nginx 监控脚本内容如下
[root@bnginx-vm001 scripts]# cat ngx_status.sh
#!/bin/bash
HOST="192.168.0.12"
function exist {
/sbin/pidof nginx | wc -l
}
function active {
/usr/bin/curl "http://$HOST/status" 2>/dev/null | egrep "Active" | awk '{print $NF}'
}
function reading {
/usr/bin/curl "http://$HOST/status/" 2>/