使用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

  状态页用于输出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 ~]#

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

三.监控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]"

四.自定义Nginx的监控模板

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

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

1>.点击创建主机

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

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

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

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

6>.主机模板添加成功

7>.nginx主机监控成功

8>.查看nginx模板的图形

使用Zabbix监控Nginx服务实战案例的更多相关文章

  1. 【zabbix告警监控】配置zabbix监控nginx服务

    zabbix监控nginx,nginx需要添加--with-http_stub_status模块 使用zabbix监控nginx,首先nginx需要配置开启ngx_status.但是我这边nginx安 ...

  2. zabbix监控nginx服务状态

    nginx需要安装--with-http_stub_status_module模块 $ nginx -V nginx version: nginx/1.12.2 built by gcc 4.8.5 ...

  3. Zabbix 监控 Nginx(四)

    简介: 如何使用 Zabbix 监控 Nginx 状态 ? 1.获取 Nginx 状态( HTTP Stub Status ) [root@localhost ~]# /apps/product/ng ...

  4. Zabbix 监控 Nginx 状态

    简介: 如何使用 Zabbix 监控 Nginx 状态 ? 1.获取 Nginx 状态( HTTP Stub Status ) shell > /usr/local/nginx/sbin/ngi ...

  5. zabbix监控nginx连接状态(转)

    zabbix监控nginx zabbix可以监控nginx的状态,关于一个服务的状态可以查看服务本身的状态(版本号.是否开启),还应该关注服务能力(例如以nginx的负载效果:连接数.请求数和句柄数) ...

  6. 使用zabbix监控nginx的活动连接数

    使用zabbix监控nginx的活动连接数 1.方法简述 zabbix可以自定义很多监控,只要是能通过命令获取到相关的值,就可以在zabbix的监控中增加该对象进行监控,在zabbix中,该对象称之为 ...

  7. zabbix监控nginx+php-fpm,mysql+主从复制+高可用,tomcat,redis web状态

    zabbix监控对象区分 使用SNMP监控交换 使用IPMI监控服务器硬件 使用Agent监控服务器 使用JMX监控JAVA SNMP监控流程 交换机上开启snmp 在zabbix上添加监控(设置SN ...

  8. zabbix java gateway配置实战案例

    zabbix java gateway配置实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.部署tomcat服务 博主推荐阅读: CentOS: https://www. ...

  9. Python 监控nginx服务是否正常

    Python 监控nginx服务是否正常 #!/usr/bin/env python import os, sys, time from time import strftime while True ...

随机推荐

  1. mysql之指定为definer的用户不存在

    问题描述: java.sql.SQLException: The user specified as a definer ('tsingsoft'@'%') does not exist 解决: 1. ...

  2. Vagrant 安装使用

    先安装虚拟机 https://www.virtualbox.org/ 再安装 https://www.vagrantup.com/  1.nginxhttp://nginx.org/download/ ...

  3. windows系统下hosts文件的改写(为了测试nginx内网的证书代理,需要做域名解析)

    1. win加R     C:\WINDOWS\system32\drivers\etc 2.打开hosts文件  加入一行  IP为客户机要访问的IP地址  域名也是在nginx中定义好的 3.ct ...

  4. 法兰克因恶意软件感染而关闭了整个IT网络

    导读 现在,越来越多的黑客组织将目标对准大型企业和政府机构.对于黑客而言,这比感染家庭用户具有更高的潜在利益.由于勒索软件的攻击,许多市政网络已被暂时关闭,而这次法兰克福遇到了恶意软件. 法兰克福是世 ...

  5. 监听EditView中的文本改变事件详解--转

    转自: http://blog.csdn.net/zoeice/article/details/7700529 android中的编辑框EditText也比较常用,那比如在搜索框中,没输入一个字,下面 ...

  6. Linux centosVMware Apache 配置防盗链、访问控制Directory、访问控制FilesMatch

    一.配置防盗链 通过限制referer来实现防盗链的功能 配置文件增加如下内容 vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf //改为如下 ...

  7. Color Space 和 Color Range

    颜色有两个属性Color Range和Color Space 有关Color Space的解释可以看下面两个链接: https://www.jianshu.com/p/facdbab5ac20 htt ...

  8. 63 滑动窗口的最大值 &&front(),back()操作前一定要判断容器的尺寸不能为0

    给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值.例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6, ...

  9. HIHOcoder编程总结

    [Offer收割]编程练习赛44 对于第一题题目1 : 扫雷游戏,首先要想清楚思路,虽然是暴力算法,但是这八个方向要自己把坐标写正确,不要慌乱,自己写的时候就写错了一个,第二个就是判断的时候,j + ...

  10. 电脑中安装了两个版本的jdk,后装的会把第一个覆盖掉

    电脑中之前装过一个1.8的jdk,后来工作需要又装了个1.7的,但是1.7的没有在系统环境变量中进行配置,而是通过setclasspath文件设置的,但是后来我发现,虽然没有改变系统环境变量中的JAV ...