|
Today's Web site traffic suddenly increased, monitoring the alarm is my room bandwidth all ran full, and finally the hardware firewall policy changes before returning to normal. Then the person in charge to the site on the nginx, and the bandwidth of the state, so I thought to do this, mainly Zabbix monitoring some of the link state nginx:
1, first open the nginx_status module monitoring functions:
Server {
Listen 8067;
Server_name localhost;
Root html;
Index index.html;
Access_log off;
Location / status {
Stub_status on;
}}
}}
2, the 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, the preparation of script filtering data: (zabbix main data will be able to figure):
[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, open the zabbix scripting function, I am now accustomed to the implementation of the key, on another path, after the file a good distinction, we should also recommend doing so:
[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 templates: modules in my annex can be downloaded:
Here demo, at the time I made the first time, so forget to add graphics, and we can add their own graphics based on the template, there is no trigger I have not created, we need to create their own
Summary: zabbix can be very good application to monitor, is still very strong, and slowly study |
|
|
|