zabbix 모니터링 Nginx 추가

21575 단어
  • nginx 설정 주의: ngxstatus 이름 은 셸 스 크 립 트 에 대응 하 는 이름 과 같 아야 합 니 다
    location ~ /ngx_status {
         stub_status on;
         access_log off;
         allow 127.0.0.1;
         allow 192.168.1.0/24;
         deny all;
     }
    
  • zabbix 설정agentd.conf
           UserParameter=nginx.status[*],/scripts/ngx_status.sh $1
    
  • 셸 스 크 립 트 설정: 스 크 립 트 이름과 zabbixagented. conf 의 이름 이 같 습 니 다
         #!/bin/bash
         ##############################################################
         # File Name: ngx_status.sh
         # Version: V1.0
         # Author: Tim
         # Organization: opensource
         # Created Time : 2017-06-06 15:27:06
         # Description:
         ##############################################################
         
         
         HOST="192.168.0.199"
         PORT="80"
         
         function ping {
             /sbin/pidof nginx | wc -l
         }
         
         function active {
             /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null | grep "Active" | awk '{print $NF}'
         }
         
         function reading {
             /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null | grep "Reading" | awk '{print $2}'
         }
         
         function writing {
             /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null | grep "Writing" | awk '{print $4}'
         }
         
         function waiting {
             /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null | grep "Waiting"| awk '{print $6}'
         }
         
         function accepts {
             /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null | awk NR==3 | awk '{print $1}'
         }
         
         function handled {
             /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null | awk NR==3 | awk '{print $2}'
         }
         
         function requests {
             /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null | awk NR==3 | awk '{print $3}'
         }
         
         $1
    
  • nginx 가 져 오기zbx_export_templates.xml
     
     
         3.2
         2017-06-08T01:12:31Z
         
             
                 Templates
             
         
         
             
         
         
             
                 Nginx_status
                 900
                 200
                 0.0000
                 100.0000
                 1
                 1
                 0
                 1
                 0
                 0.0000
                 0.0000
                 0
                 0
                 0
                 0
                 
                     
                         0
                         0
                         7EC25C
                         0
                         2
                         0
                         
                             Template App Nginx Service
                             nginx.status[accepts]
                         
                     
                     
                         1
                         0
                         274482
                         0
                         2
                         0
                         
                             Template App Nginx Service
                             nginx.status[active]
                         
                     
                     
                         2
                         0
                         2B5429
                         0
                         2
                         0
                         
                             Template App Nginx Service
                             nginx.status[handled]
                         
                     
                     
                         3
                         0
                         8048B4
                         0
                         2
                         0
                         
                             Template App Nginx Service
                             nginx.status[reading]
                         
                     
                     
                         4
                         0
                         FD5434
                         0
                         2
                         0
                         
                             Template App Nginx Service
                             nginx.status[requests]
                         
                     
                     
                         5
                         0
                         790E1F
                         0
                         2
                         0
                         
                             Template App Nginx Service
                             nginx.status[waiting]
                         
                     
                     
                         6
                         0
                         87AC4D
                         0
                         2
                         0
                         
                             Template App Nginx Service
                             nginx.status[writing]
                         
                     
                 
             
         
     
    
  • 좋은 웹페이지 즐겨찾기