使用Zabbix监控Nginx服务实战案例

时间:2023-03-10 02:34:57
使用Zabbix监控Nginx服务实战案例

           使用Zabbix监控Nginx状态页实战案例

                                     作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。 

一.编译安装nginx步骤详解并开启状态页

  博主推荐阅读:
    https://www.cnblogs.com/yinzhengjie/p/12031651.html
    https://www.cnblogs.com/yinzhengjie/p/12045736.html
[root@nginx201.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /yinzhengjie/softwares/nginx/conf/nginx.conf
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
server {
listen ;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page /50x.html;
location = /50x.html {
root html;
}
location /nginx_status {
stub_status;
}
}
}
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# egrep -v "^ *#|^$" /yinzhengjie/softwares/nginx/conf/nginx.conf

使用Zabbix监控Nginx服务实战案例

  状态页用于输出nginx的基本状态信息,下面是关于输出信息的详细说明:
    Active connections:
      当前处于活动状态的客户端连接数,包括连接等待空闲连接数。当这个数值非常大时,我们得考虑nginx后端提供的web服务以及数据库性能上是否可以hold住。
    accepts:
      统计总值,Nginx自启动后已经接受的客户端请求的总数。对于运维来说,并没有太大的参考一样,因为如果我们长期不重启nginx服务,那么这个数字可能会很大。
    handled:
      统计总值,Nginx自启动后已经处理完成的客户端请求的总数,通常等于accepts,除非有因worker_connections限制等被拒绝的连接。同理,这个参数的参考意义对运维人员来说也不大。
    requests:
      统计总值,Nginx自启动后客户端发来的总的请求数。这个数值会很大,因为一个链接会有多个请求。
    Reading:
      当前状态,正在读取客户端请求报文首部的连接的连接数。即表示正在和nginx建立连接但还没有建立成功,如果这个数字很大的话,说明你的nginx服务器处理速度相对比较慢,和用户建立连接都需要排队了,所以得考虑做优化。
    Writing:
      当前状态,正在向客户端发送响应报文过程中的连接数。如果这个数字过大,可能是响应报文给客户端可能会涉及到静态资源(比如js,css,html)获取速度较慢(因为有资源是在本地服务器,有的是在后端服务器,有的资源可能没有及时响应)会导致整个响应过程很慢。
    Waiting:
      当前状态,正在等待客户端发出请求的空闲连接数,开启 keep-alive的情况下,这个值等于active – (reading+writing),

二.在Nginx服务器上部署Zabbix Agent

1>.下载zabbix源码包

  博主推荐阅读:
    https://www.cnblogs.com/yinzhengjie2020/p/12305427.html

2>.安装依赖包

[root@nginx201.yinzhengjie.org.cn ~]# tar zxf zabbix-4.0..tar.gz

3>.配置安装参数

[root@nginx201.yinzhengjie.org.cn ~]# cd zabbix-4.0./
[root@nginx201.yinzhengjie.org.cn ~/zabbix-4.0.]#
[root@nginx201.yinzhengjie.org.cn ~/zabbix-4.0.]# ./configure --prefix=/yinzhengjie/softwares/zabbix --enable-agent

4>.编译并安装zabbix agent

[root@nginx201.yinzhengjie.org.cn ~]# lscpu
Architecture: x86_64
CPU op-mode(s): -bit, -bit
Byte Order: Little Endian
CPU(s):
On-line CPU(s) list: ,
Thread(s) per core:
Core(s) per socket:
Socket(s):
NUMA node(s):
Vendor ID: GenuineIntel
CPU family:
Model:
Model name: Intel(R) Core(TM) i7-8750H CPU @ .20GHz
Stepping:
CPU MHz: 2207.997
BogoMIPS: 4415.99
Virtualization: VT-x
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 9216K
NUMA node0 CPU(s): ,
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid s
se4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap xsaveopt arat spec_ctrl intel_stibp flush_l1d
arch_capabilities
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# lscpu | grep "^CPU(s)"
CPU(s):
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# lscpu | grep "^CPU(s)"

[root@nginx201.yinzhengjie.org.cn ~/zabbix-4.0.]# make -j  && make install

5>.修改agent端的配置文件

[root@nginx201.yinzhengjie.org.cn ~]# cp /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf-`date +%F`
[root@nginx201.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/
total
drwxr-xr-x root root Feb : bin
drwxr-xr-x root root Feb : etc
drwxr-xr-x root root Feb : lib
drwxr-xr-x root root Feb : sbin
drwxr-xr-x root root Feb : share
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# mkdir -v /yinzhengjie/softwares/zabbix/pid
mkdir: created directory ‘/yinzhengjie/softwares/zabbix/pid’
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/
total
drwxr-xr-x root root Feb : bin
drwxr-xr-x root root Feb : etc
drwxr-xr-x root root Feb : lib
drwxr-xr-x root root Feb : pid
drwxr-xr-x root root Feb : sbin
drwxr-xr-x root root Feb : share
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# mkdir -v /yinzhengjie/softwares/zabbix/pid

[root@nginx201.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/
total
drwxr-xr-x root root Feb : bin
drwxr-xr-x root root Feb : etc
drwxr-xr-x root root Feb : lib
drwxr-xr-x root root Feb : pid
drwxr-xr-x root root Feb : sbin
drwxr-xr-x root root Feb : share
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# mkdir -v /yinzhengjie/softwares/zabbix/logs
mkdir: created directory ‘/yinzhengjie/softwares/zabbix/logs’
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/
total
drwxr-xr-x root root Feb : bin
drwxr-xr-x root root Feb : etc
drwxr-xr-x root root Feb : lib
drwxr-xr-x root root Feb : logs
drwxr-xr-x root root Feb : pid
drwxr-xr-x root root Feb : sbin
drwxr-xr-x root root Feb : share
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# mkdir -v /yinzhengjie/softwares/zabbix/logs mkdir: created directory ‘/yinzhengjie/softwares/zabbix/logs’

[root@nginx201.yinzhengjie.org.cn ~]# grep ^LogFile= /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# sed -r -i 's#(LogFile=)/tmp#\1/yinzhengjie/softwares/zabbix/logs#' /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# grep ^LogFile= /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
LogFile=/yinzhengjie/softwares/zabbix/logs/zabbix_agentd.log
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# sed -r -i 's#(LogFile=)/tmp#\1/yinzhengjie/softwares/zabbix/logs#' /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf

[root@nginx201.yinzhengjie.org.cn ~]# grep PidFile= /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
# PidFile=/tmp/zabbix_agentd.pid
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# sed -r -i 's@# (PidFile=)/tmp@\1/yinzhengjie/softwares/zabbix/pid@' /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# grep PidFile= /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
PidFile=/yinzhengjie/softwares/zabbix/pid/zabbix_agentd.pid
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# sed -r -i 's@# (PidFile=)/tmp@\1/yinzhengjie/softwares/zabbix/pid@' /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf

[root@nginx201.yinzhengjie.org.cn ~]# grep ^Server= /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
Server=127.0.0.1
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# sed -r -i 's#(Server=)127.0.0.1#\1172.200.5.203#' /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# grep ^Server= /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
Server=172.200.5.203
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# sed -r -i 's#(Server=)127.0.0.1#\1172.200.5.203#' /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf

[root@nginx201.yinzhengjie.org.cn ~]# grep ^Hostname= /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
Hostname=Zabbix server
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# sed -r -i 's#(Hostname=)Zabbix server#\1nginx201.yinzhengjie.org.cn#' /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# grep ^Hostname= /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
Hostname=nginx201.yinzhengjie.org.cn
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# sed -r -i 's#(Hostname=)Zabbix server#\1nginx201.yinzhengjie.org.cn#' /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf

6>.并创建zabbix用户 

[root@nginx201.yinzhengjie.org.cn ~]# groupadd zabbix
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# useradd zabbix -s /sbin/nologin -M -g zabbix
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# chown zabbix:zabbix /yinzhengjie/softwares/zabbix/ -R
[root@nginx201.yinzhengjie.org.cn ~]#

使用Zabbix监控Nginx服务实战案例

7>.编写zabbix agent端的启动脚本并配置其开机自启动

[root@nginx201.yinzhengjie.org.cn ~]# vim /lib/systemd/system/zabbix-agent.service
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# cat /lib/systemd/system/zabbix-agent.service
[Unit]
Description=Yinzhengjie's Zabbix Agent
After=syslog.target
After=network.target [Service]
Environment="CONFFILE=/yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf"
EnvironmentFile=-/etc/default/zabbix-agent
Type=forking
Restart=on-failure
PIDFile=/yinzhengjie/softwares/zabbix/pid/zabbix_agentd.pid
KillMode=control-group
ExecStart=/yinzhengjie/softwares/zabbix/sbin/zabbix_agentd -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
User=zabbix
Group=zabbix [Install]
WantedBy=multi-user.target
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# vim /lib/systemd/system/zabbix-agent.service

[root@nginx201.yinzhengjie.org.cn ~]# systemctl daemon-reload
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# systemctl start zabbix-agent.service
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# systemctl list-unit-files | grep zabbix-agent.service
zabbix-agent.service enabled
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# systemctl status zabbix-agent.service
● zabbix-agent.service - Yinzhengjie's Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
Active: active (running) since Fri -- :: CST; 2min 41s ago
Main PID: (zabbix_agentd)
CGroup: /system.slice/zabbix-agent.service
├─ /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd -c /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
├─ /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: collector [idle sec]
├─ /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener # [waiting for connection]
├─ /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener # [waiting for connection]
├─ /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener # [waiting for connection]
└─ /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: active checks # [idle sec] Feb :: nginx201.yinzhengjie.org.cn systemd[]: Starting Yinzhengjie's Zabbix Agent...
Feb :: nginx201.yinzhengjie.org.cn systemd[]: Can't open PID file /yinzhengjie/softwares/zabbix/pid/zabbix_agentd.pid (yet?) after start: No such file or directory
Feb :: nginx201.yinzhengjie.org.cn systemd[]: Started Yinzhengjie's Zabbix Agent.
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# systemctl status zabbix-agent.service

使用Zabbix监控Nginx服务实战案例

三.监控Nginx实战案例

1>.编写nginx的自定义监控脚本

[root@nginx201.yinzhengjie.org.cn ~]# vim /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf.d/check_nginx.sh
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf.d/check_nginx.sh
#!/bin/bash
#
host=${:-'127.0.0.1'}
port=${:-''}
page=${:-'nginx_status'}
info=$(/usr/bin/curl --connect-timeout -s http://${host}:${port}/${page} 2>/dev/null)
code=$(/usr/bin/curl --connect-timeout -o /dev/null -s -w %{http_code} http://${host}:${port}/${page})
proc=$(/usr/bin/pgrep nginx | wc -l) case "$1" in
status)
echo "$code $proc" | awk '{code=$1}{proc=$2}END{if(code == "200" && proc != 0){printf("%d\n",1)}else{printf("%d\n",0)}}'
;;
active)
echo "$info" | awk '/^Active/{var=$NF}END{if(var~/^[0-9]+$/){printf("%d\n",var)}else{printf("%d\n",0)}}'
;;
reading)
echo "$info" | awk '/Reading/ {print $2}'
;;
writing)
echo "$info" | awk '/Writing/ {print $4}'
;;
waiting)
echo "$info" | awk '/Waiting/ {print $6}'
;;
accepts)
echo "$info" | awk 'NR==3 {print $1}'
;;
handled)
echo "$info" | awk 'NR==3 {print $2}'
;;
requests)
echo "$info" | awk 'NR==3 {print $3}'
;;
restimes)
echo "$info" | awk 'BEGIN{OFMT="%.3f"} NR==3 {print $4/$3}'
;;
*)
echo "ZBX_NOTSUPPORTED"
;;
esac
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# vim /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf.d/check_nginx.sh

2>.修改自定义的监控脚本权限

[root@nginx201.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf.d/
total
-rw-r--r-- root root Feb : check_nginx.sh
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# chmod +x /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf.d/check_nginx.sh
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf.d/
total
-rwxr-xr-x root root Feb : check_nginx.sh
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# chmod +x /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf.d/check_nginx.sh

3>.修改zabbix agent的配置文件让其支持自定义监控项功能

[root@nginx201.yinzhengjie.org.cn ~]# grep "# UserParameter=" /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
# UserParameter=
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# sed -r -i "s@# (UserParameter=)@\1nginx.status[*],/yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf.d/check_nginx.sh \$1 \$2 \$3@" /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# grep "^UserParameter=" /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
UserParameter=nginx.status[*],/yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf.d/check_nginx.sh $ $ $
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# sed -r -i "s@# (UserParameter=)@\1nginx.status[*],/yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf.d/check_nginx.sh \$1 \$2 \$3@" /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf

4>.重启zabbix agent服务使得配置生效

[root@nginx201.yinzhengjie.org.cn ~]# ps -ef | grep zabbix
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd -c /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: collector [idle sec]
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener # [waiting for connection]
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener # [waiting for connection]
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener # [waiting for connection]
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: active checks # [idle sec]
root : pts/ :: grep --color=auto zabbix
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN *: *:*
LISTEN *: *:*
LISTEN *: *:*
LISTEN *: *:*
LISTEN ::: :::*
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# systemctl restart zabbix-agent.service
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN *: *:*
LISTEN *: *:*
LISTEN *: *:*
LISTEN *: *:*
LISTEN ::: :::*
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]# ps -ef | grep zabbix
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd -c /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: collector [idle sec]
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener # [waiting for connection]
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener # [waiting for connection]
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener # [waiting for connection]
zabbix : ? :: /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: active checks # [idle sec]
root : pts/ :: grep --color=auto zabbix
[root@nginx201.yinzhengjie.org.cn ~]#
[root@nginx201.yinzhengjie.org.cn ~]#

[root@nginx201.yinzhengjie.org.cn ~]# systemctl restart zabbix-agent.service

5>.在zabbix server端使用zabbix_get命令行进行测试

[root@zabbix203.yinzhengjie.org.cn ~]# /yinzhengjie/softwares/zabbix/bin/zabbix_get -s nginx201.yinzhengjie.org.cn -p  -k "nginx.status[status]"

使用Zabbix监控Nginx服务实战案例

四.自定义Nginx的监控模板

  博主推荐阅读:
    https://www.cnblogs.com/yinzhengjie2020/p/12340063.html

五.使用自定义的Nginx模板监控nginx服务

1>.点击创建主机

使用Zabbix监控Nginx服务实战案例

2>.填写nginx的主机监控信息

使用Zabbix监控Nginx服务实战案例

3>.选择咱们自定义的Nginx监控模板

使用Zabbix监控Nginx服务实战案例

4>.如下图所示,点击"添加"按钮,添加链接的模板

使用Zabbix监控Nginx服务实战案例

5>.为Nginx主机关联多个模板并点击"添加"按钮

使用Zabbix监控Nginx服务实战案例

6>.主机模板添加成功

使用Zabbix监控Nginx服务实战案例

7>.nginx主机监控成功

使用Zabbix监控Nginx服务实战案例

8>.查看nginx模板的图形

使用Zabbix监控Nginx服务实战案例