Zabbix Monitoring Nginx_status

Source: Internet
Author: User
Tags curl

Environment:

Zabbix 2.0

Zabbix server:172.28.2.119

Zabbix Nginx Client: 172.28.2.151

The premise is that nignx when compiling the installation:--with-http_stub_status_module-----This everybody knows!!

Also, add the following in the Nginx configuration file:

Location/status    
    {    
       stub_status on;    
       Access_lod off;    
       Allow 127.0.0.1;    
       Allow 172.28.2.119;    #这是我们zabbix监控服务器IP    
    }

The following Zabbix on the Nginx monitoring principle:

Zabbix Server <---(Zabbix Agent)---> Nginx client key (to be written to the client configuration file) <---script--->nginx state parameters

The Nginx Web interface nginx status is shown in the following figure:

1. Create a status parameter to get Nginx data transfer to server-side script

[Root@zabbix_server script]# cat >>/usr/local/sbin/nginx_status.sh << EOF #!/bin/bash # script to FE tch Nginx statuses for tribily monitoring systems # license:gplv4 # Set Variables bkup_date= '/bin/date +%y%m% d ' log= "/etc/zabbix/nginx_status.log" #HOST = '/sbin/ifconfig eth0 |    
Sed-n '/inet/{s/.*addr://;s/. *//;p} ' host= '/sbin/ifconfig eth0 "|grep inet addr" |awk-f[: ""] ' {print $} ' Port= # functions to return Nginx stats function active {/usr/bin/curl ' http://$HOST: $PORT/statu S "2>/dev/null| grep ' Active ' | awk ' {print $NF} '} function reading {/usr/bin/curl "http://$HOST: $PORT/status" 2>/dev/nul l| grep ' Reading ' | awk ' {print $} '} function writing {/usr/bin/curl "http://$HOST: $PORT/status" 2>/dev/null | grep ' Writing ' | awk ' {print $} '} function waiting {/usr/bin/curl "http://$HOST: $PORT/status" 2>/dev/null | grep ' Waiting ' | awk ' {print $} '} function accepts {/usr/bin/curl "http://$HOST: $PORT/status" 2>/dev/null | awk nr==3 | awk ' {print} '} ' function handled {/usr/bin/curl ' http://$HOST: $PORT/status ' 2>/dev/null| awk N r==3 |  awk ' {print $} '} function requests {/usr/bin/curl ' http://$HOST: $PORT/status ' 2>/dev/null| awk nr==3 | awk ' {print $} '} # Run the requested function ' EOF '

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/web/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.