Zabbix monitors Nginx status

Source: Internet
Author: User

Zabbix monitors Nginx status

Today, the website traffic suddenly increased. The monitoring and alarm service fully occupied all the bandwidth of my data center. Finally, the hardware firewall policy was changed before it went back to normal. Then the person in charge asked about the nginx website and the bandwidth status, so he remembered to do this, mainly because Zabbix monitored some of the nginx link statuses:

1. enable the monitoring function of the nginx_status module:
Server {
Listen 8067;
Server_name localhost;
Root html;
Index index.html;
Access_log off;
Location/status {
Stub_status on;
}
}

2. test:
[Root @ WEB_007 vhosts] # curl http: // 192.168.10.7: 8067/status
Active connections: 3
Server accepts handled requests
1305214152 1305214152 1305204005
Reading: 0 Writing: 3 Waiting: 0

3. Write a script to filter data: (zabbix can plot data if there is data ):
[Root @ WEB_007 vhosts] # cat/usr/local/zabbix/scripts/nginx_status
#! /Bin/bash
# Script to fetch nginx statuses for tribily monitoring systems
# Author: xiaoluo
# License: GPLv2

Function active {
/Usr/bin/curl "http: // 192.168.10.7: 8067/status" 2>/dev/null | grep 'active' | awk '{print $ NF }'
}
Function reading {
/Usr/bin/curl "http: // 192.168.10.7: 8067/status" 2>/dev/null | grep 'reading' | awk '{print $2 }'
}
Function writing {
/Usr/bin/curl "http: // 192.168.10.7: 8067/status" 2>/dev/null | grep 'writing' | awk '{print $4 }'
}
Function waiting {
/Usr/bin/curl "http: // 192.168.10.7: 8067/status" 2>/dev/null | grep 'waiting' | awk '{print $6 }'
}
Function accepts {
/Usr/bin/curl "http: // 192.168.10.7: 8067/status" 2>/dev/null | awk NR = 3 | awk '{print $1 }'
}
Function handled {
/Usr/bin/curl "http: // 192.168.10.7: 8067/status" 2>/dev/null | awk NR = 3 | awk '{print $2 }'
}
Function requests {
/Usr/bin/curl "http: // 192.168.10.7: 8067/status" 2>/dev/null | awk NR = 3 | awk '{print $3 }'
}
# Run the requested function
$1

4. When the zabbix Script Function is enabled, I am used to storing the executed key in another path. In the future, there will be many differences between the files. We suggest doing the same:
[Root @ WEB_007 zabbix_agentd.conf.d] # vi/usr/local/zabbix/etc/zabbix_agentd.conf
UnsafeUserParameters = 1
Include =/usr/local/zabbix/etc/zabbix_agentd.conf.d/
[Root @ WEB_007 zabbix_agentd.conf.d] # cd/usr/local/zabbix/etc/zabbix_agentd.conf.d/
[Root @ WEB_007 zabbix_agentd.conf.d] # vi nginx
# Monitor nginx
UserParameter = nginx [*],/usr/local/zabbix/scripts/nginx_status $1

5. Import template: you can download the module from my attachment:
This is a demonstration. At that time, I created the image for the first time, so I forgot to add the image. You can add the Image Based on the template, and I have not created any triggers. You can create them based on your own needs.

6. Graphic Display Effect:

Conclusion: zabbix can be well monitored based on applications. It is still very powerful and will be studied slowly.

The template is downloaded by yourself below:

------------------------------------------ Split line ------------------------------------------

Free in http://linux.bkjia.com/

The username and password are both www.bkjia.com

The specific download directory is/July 6,/July 14/Zabbix monitoring Nginx status/

For the download method, see

------------------------------------------ Split line ------------------------------------------

Some Zabbix Tutorials:

Install and deploy the distributed monitoring system Zabbix 2.06

Install and deploy the distributed monitoring system Zabbix 2.06

Install and deploy Zabbix in CentOS 6.3

Zabbix distributed monitoring system practice

Under CentOS 6.3, Zabbix monitors apache server-status

Monitoring MySQL database Parameters Using Zabbix in CentOS 6.3

Install Zabbix 2.0.6 in 64-bit CentOS 6.2

ZABBIX details: click here
ZABBIX: click here

This article permanently updates the link address:

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.