zabbix nginx 템 플 릿

25999 단어
zabbix 서버 nginx 의 업로드 파일 제한 수정: clientmax_body_size 5m;
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: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
                
            
        
    

좋은 웹페이지 즐겨찾기