zoukankan      html  css  js  c++  java
  • 使用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  1;
    events {
        worker_connections  1024;
    }
    http {
        include       mime.types;
        default_type  application/octet-stream;
        sendfile        on;
        keepalive_timeout  65;
        server {
            listen       80;
            server_name  localhost;
            location / {
                root   html;
                index  index.html index.htm;
            }
            error_page   500 502 503 504  /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.17.tar.gz

    3>.配置安装参数

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

    4>.编译并安装zabbix agent

    [root@nginx201.yinzhengjie.org.cn ~]# lscpu 
    Architecture:          x86_64
    CPU op-mode(s):        32-bit, 64-bit
    Byte Order:            Little Endian
    CPU(s):                2
    On-line CPU(s) list:   0,1
    Thread(s) per core:    1
    Core(s) per socket:    2
    Socket(s):             1
    NUMA node(s):          1
    Vendor ID:             GenuineIntel
    CPU family:            6
    Model:                 158
    Model name:            Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Stepping:              10
    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):     0,1
    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):                2
    [root@nginx201.yinzhengjie.org.cn ~]# 
    [root@nginx201.yinzhengjie.org.cn ~]# lscpu | grep "^CPU(s)"
    [root@nginx201.yinzhengjie.org.cn ~/zabbix-4.0.17]# make -j 2 && 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 0
    drwxr-xr-x 2 root root 45 Feb 21 19:28 bin
    drwxr-xr-x 3 root root 60 Feb 21 19:32 etc
    drwxr-xr-x 3 root root 21 Feb 21 19:28 lib
    drwxr-xr-x 2 root root 27 Feb 21 19:28 sbin
    drwxr-xr-x 3 root root 17 Feb 21 19:28 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 0
    drwxr-xr-x 2 root root 45 Feb 21 19:28 bin
    drwxr-xr-x 3 root root 60 Feb 21 19:32 etc
    drwxr-xr-x 3 root root 21 Feb 21 19:28 lib
    drwxr-xr-x 2 root root  6 Feb 21 19:33 pid
    drwxr-xr-x 2 root root 27 Feb 21 19:28 sbin
    drwxr-xr-x 3 root root 17 Feb 21 19:28 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 0
    drwxr-xr-x 2 root root 45 Feb 21 19:28 bin
    drwxr-xr-x 3 root root 60 Feb 21 19:32 etc
    drwxr-xr-x 3 root root 21 Feb 21 19:28 lib
    drwxr-xr-x 2 root root  6 Feb 21 19:33 pid
    drwxr-xr-x 2 root root 27 Feb 21 19:28 sbin
    drwxr-xr-x 3 root root 17 Feb 21 19:28 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 0
    drwxr-xr-x 2 root root 45 Feb 21 19:28 bin
    drwxr-xr-x 3 root root 60 Feb 21 19:32 etc
    drwxr-xr-x 3 root root 21 Feb 21 19:28 lib
    drwxr-xr-x 2 root root  6 Feb 21 19:34 logs
    drwxr-xr-x 2 root root  6 Feb 21 19:33 pid
    drwxr-xr-x 2 root root 27 Feb 21 19:28 sbin
    drwxr-xr-x 3 root root 17 Feb 21 19:28 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 2020-02-21 19:44:42 CST; 2min 41s ago
     Main PID: 20201 (zabbix_agentd)
       CGroup: /system.slice/zabbix-agent.service
               ├─20201 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd -c /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
               ├─20202 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]
               ├─20203 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener #1 [waiting for connection]
               ├─20204 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener #2 [waiting for connection]
               ├─20205 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener #3 [waiting for connection]
               └─20206 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
    
    Feb 21 19:44:42 nginx201.yinzhengjie.org.cn systemd[1]: Starting Yinzhengjie's Zabbix Agent...
    Feb 21 19:44:42 nginx201.yinzhengjie.org.cn systemd[1]: Can't open PID file /yinzhengjie/softwares/zabbix/pid/zabbix_agentd.pid (yet?) after start: No such file or directory
    Feb 21 19:44:42 nginx201.yinzhengjie.org.cn systemd[1]: 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=${2:-'127.0.0.1'}
    port=${3:-'80'}
    page=${4:-'nginx_status'}
    info=$(/usr/bin/curl --connect-timeout 5 -s http://${host}:${port}/${page} 2>/dev/null)
    code=$(/usr/bin/curl --connect-timeout 5 -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
    ",1)}else{printf("%d
    ",0)}}'
        ;;
      active)
        echo "$info" | awk '/^Active/{var=$NF}END{if(var~/^[0-9]+$/){printf("%d
    ",var)}else{printf("%d
    ",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 4
    -rw-r--r-- 1 root root 1092 Feb 21 23:42 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 4
    -rwxr-xr-x 1 root root 1092 Feb 21 23:42 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 $1 $2 $3
    [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    20587      1  0 00:01 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd -c /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
    zabbix    20588  20587  0 00:01 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]
    zabbix    20589  20587  0 00:01 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener #1 [waiting for connection]
    zabbix    20590  20587  0 00:01 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener #2 [waiting for connection]
    zabbix    20591  20587  0 00:01 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener #3 [waiting for connection]
    zabbix    20592  20587  0 00:01 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
    root      20677  20440  0 00:02 pts/1    00:00:00 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     0      128                                                                                                         *:111                                                                                                                     *:*                  
    LISTEN     0      511                                                                                                         *:80                                                                                                                      *:*                  
    LISTEN     0      128                                                                                                         *:22                                                                                                                      *:*                  
    LISTEN     0      128                                                                                                         *:10050                                                                                                                   *:*                  
    LISTEN     0      128                                                                                                        :::22                                                                                                                     :::*                  
    [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     0      128                                                                                                         *:111                                                                                                                     *:*                  
    LISTEN     0      511                                                                                                         *:80                                                                                                                      *:*                  
    LISTEN     0      128                                                                                                         *:22                                                                                                                      *:*                  
    LISTEN     0      128                                                                                                         *:10050                                                                                                                   *:*                  
    LISTEN     0      128                                                                                                        :::22                                                                                                                     :::*                  
    [root@nginx201.yinzhengjie.org.cn ~]# 
    [root@nginx201.yinzhengjie.org.cn ~]# ps -ef | grep zabbix
    zabbix    20689      1  0 00:03 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd -c /yinzhengjie/softwares/zabbix/etc/zabbix_agentd.conf
    zabbix    20690  20689  0 00:03 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]
    zabbix    20691  20689  0 00:03 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener #1 [waiting for connection]
    zabbix    20692  20689  0 00:03 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener #2 [waiting for connection]
    zabbix    20693  20689  0 00:03 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: listener #3 [waiting for connection]
    zabbix    20694  20689  0 00:03 ?        00:00:00 /yinzhengjie/softwares/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
    root      20697  20440  0 00:03 pts/1    00:00:00 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 10050 -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模板的图形

  • 相关阅读:
    使用maven创建web项目
    SSM框架——使用MyBatis Generator自动创建代码
    java中微信统一下单采坑(app微信支付)
    mac的safari浏览器调试h5
    服务端调用高德地图api实现ip定位城市
    mvn打包时,出现数据库连接错误
    其他知识点收集
    linux中项目占用cpu、内存过高时的排查经历
    linux中安装mysql
    linux中jdk的安装与配置
  • 原文地址:https://www.cnblogs.com/yinzhengjie2020/p/12339823.html
Copyright © 2011-2022 走看看