zabbix nginx 템 플 릿
nginx 클 라 이언 트 오픈 상태 검사
nginx server { listen 80; server_name localhost;
location /stub_status {
    stub_status on;
    access_log off;
    allow 127.0.0.1;
    deny all;
}
}
zabbix 클 라 이언 트 설정 스 크 립 트 명령
cat /etc/zabbix/zabbix_agentd.d/userparameter_nginx.conf UserParameter=nginx.status[*],/etc/zabbix/scripts/nginx.sh $1
nginx. sh 스 크 립 트
mkdir -p /etc/zabbix/scripts vim /etc/zabbix/scripts/nginx.sh
#!/bin/bash
##################################################
# AUTHOR: Neo 
# WEBSITE: http://www.netkiller.cn
# Description:zabbix    status      nginx
# Note:Zabbix 3.2
# DateTime: 2016-11-22
##################################################
HOST="localhost"
PORT="80"
stub_status=stub_status
function check() {
    if [ -f /sbin/pidof ]; then
       /sbin/pidof nginx | wc -w
    else
       ps ax | grep "nginx:" | grep -v grep | wc -l
    fi
}
function active() {
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Active' | awk '{print $NF}'
}
function accepts() {
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $1}'
}
function handled() {
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $2}'
}
function requests() {
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $3}'
}
function reading() {
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Reading' | awk '{print $2}'
}
function writing() {
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Writing' | awk '{print $4}'
}
function waiting() {
    /usr/bin/curl -s "http://$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Waiting' | awk '{print $6}'
}
case "$1" in
    check)
        check
        ;;
    active)
        active
        ;;
    accepts)
        accepts
        ;;
    handled)
        handled
        ;;
    requests)
        requests
        ;;
    reading)
        reading
        ;;
    writing)
        writing
        ;;
    waiting)
        waiting
        ;;
    *)
        echo $"Usage $0 {check|active|accepts|handled|requests|reading|writing|waiting}"
        exit        
esac
#zabbix   
chmod +x /srv/zabbix/libexec/nginx.sh
# /srv/zabbix/libexec/nginx.sh
Usage /srv/zabbix/libexec/nginx.sh {active|accepts|handled|requests|reading|writing|waiting}
# /srv/zabbix/libexec/nginx.sh accepts
82
# systemctl restart zabbix-agent.service
#zabbix      
#nginx.xml
    3.2 
    2016-11-29T07:05:44Z 
    
        
            Netkiller 
         
        
            Templates 
         
     
    
        
            Template App Nginx
            Template App Nginx 
            Nginx Template - http://www.netkiller.cn 
            
                
                    Netkiller 
                 
                
                    Templates 
                 
             
            
                
                    nginx 
                 
             
            
                - 
                    nginx status server accepts 0 
                    0 
                    nginx.status[accepts] 60 90 365 0 3 
                    
                    1 
                    
                    0 0 
                    0 
                    1 
                    
                    
                    0 0 
                    
                    
                    
                    
                    accepts 0 
                        
                            nginx 
 
 
                    
                 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
- 
                    nginx status connections active 0 
                    0 
                    nginx.status[active] 60 90 365 0 3 
                    
                    0 
                    
                    0 0 
                    0 
                    1 
                    
                    
                    0 0 
                    
                    
                    
                    
                    active 0 
                        
                            nginx 
 
 
                    
                 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
- 
                    nginx process 0 
                    0 
                    nginx.status[check] 60 30 365 0 3 
                    
                    0 
                    
                    0 0 
                    0 
                    1 
                    
                    
                    0 0 
                    
                    
                    
                    
                    is live 0 
                        
                            nginx 
 
 
                        Service state 
 
                 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
- 
                    nginx status server handled 0 
                    0 
                    nginx.status[handled] 60 90 365 0 3 
                    
                    1 
                    
                    0 0 
                    0 
                    1 
                    
                    
                    0 0 
                    
                    
                    
                    
                    handled 0 
                        
                            nginx 
 
 
                    
                 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
- 
                    nginx status connections reading 0 
                    0 
                    nginx.status[reading] 60 90 365 0 3 
                    
                    0 
                    
                    0 0 
                    0 
                    1 
                    
                    
                    0 0 
                    
                    
                    
                    
                    reading 0 
                        
                            nginx 
 
 
                    
                 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
- 
                    nginx status server requests 0 
                    0 
                    nginx.status[requests] 60 90 365 0 3 
                    
                    1 
                    
                    0 0 
                    0 
                    1 
                    
                    
                    0 0 
                    
                    
                    
                    
                    requests 0 
                        
                            nginx 
 
 
                    
                 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
- 
                    nginx status connections waiting 0 
                    0 
                    nginx.status[waiting] 60 90 365 0 3 
                    
                    0 
                    
                    0 0 
                    0 
                    1 
                    
                    
                    0 0 
                    
                    
                    
                    
                    waiting 0 
                        
                            nginx 
 
 
                    
                 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
- 
                    nginx status connections writing 0 
                    0 
                    nginx.status[writing] 60 90 365 0 3 
                    
                    0 
                    
                    0 0 
                    0 
                    1 
                    
                    
                    0 0 
                    
                    
                    
                    
                    writing 0 
                        
                            nginx 
 
 
                    
                 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
            
            
            
            
            
             
     
    
        
            {Template App Nginx:nginx.status[check].last()}=0 
            0 
            
            nginx was down! 
            0 
            
            
            0 
            4 
            Nginx process count: 0 
            0 
            0 
            
            
              
     
    
        
            nginx status connections 
            900 
            200 
            0.0000 
            100.0000 
            1 
            1 
            0 
            1 
            0 
            0.0000 
            0.0000 
            0 
            0 
            0 
            0 
            
                
                    0 
                    0 
                    00C800 
                    0 
                    2 
                    0 
                    - 
                        Template App Nginx nginx.status[active] 
 
                
                    1 
                    0 
                    C80000 
                    0 
                    2 
                    0 
                    - 
                        Template App Nginx nginx.status[reading] 
 
                
                    2 
                    0 
                    0000C8 
                    0 
                    2 
                    0 
                    - 
                        Template App Nginx nginx.status[waiting] 
 
                
                    3 
                    0 
                    C800C8 
                    0 
                    2 
                    0 
                    - 
                        Template App Nginx nginx.status[writing] 
 
             
         
        
            nginx status server 
            900 
            200 
            0.0000 
            100.0000 
            1 
            1 
            0 
            1 
            0 
            0.0000 
            0.0000 
            0 
            0 
            0 
            0 
            
                
                    0 
                    0 
                    00C800 
                    0 
                    2 
                    0 
                    - 
                        Template App Nginx nginx.status[accepts] 
 
                
                    1 
                    0 
                    C80000 
                    0 
                    2 
                    0 
                    - 
                        Template App Nginx nginx.status[handled] 
 
                
                    2 
                    0 
                    0000C8 
                    0 
                    2 
                    0 
                    - 
                        Template App Nginx nginx.status[requests] 
 
             
         
     
    
        
            Service state 
            
                
                    0 
                    Down 
                 
                
                    1 
                    Up 
                 
             
         
     
  이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.