: This article mainly introduces Zabbix monitoring Nginx. if you are interested in the PHP Tutorial, refer to it. Zabbix monitors Nginx
Before adding monitoring, you must emphasize that Nginx must support access in the stub_status state. Otherwise, everything will be empty talk !!!
First, zabbix monitors nginx by capturing the data provided by the Status module based on the nginx Stub Status module. If you want to enable the Stub Status module, add the parameter -- with-http_stub_status_module for example :. /configure -- user = www -- group = www -- prefix =/usr/local/nginx -- with-http_stub_status_module -- with-http_ssl_module
Add location/nginx_status {stub_status on; access_log off;} to the Nginx configuration file ;}
1. create a key for monitoring Nginx
vim /usr/local/zabbix/etc/zabbix_agentd.conf.d/nginx_status_keyUserParameter=nginx.accepts,/usr/local/zabbix/shell/nginx_status.sh accepts UserParameter=nginx.handled,/usr/local/zabbix/shell/nginx_status.sh handled UserParameter=nginx.requests,/usr/local/zabbix/shell/nginx_status.sh requests UserParameter=nginx.connections.active,/usr/local/zabbix/shell/nginx_status.sh active UserParameter=nginx.connections.reading,/usr/local/zabbix/shell/nginx_status.sh reading UserParameter=nginx.connections.writing,/usr/local/zabbix/shell/nginx_status.sh writing UserParameter=nginx.connections.waiting,/usr/local/zabbix/shell/nginx_status.sh waiting
2. create a script to monitor Nginx (remember to add the execution permission)
Vim/usr/local/zabbix/shell/nginx_status.sh #! /Bin/bash # Script to fetch nginx statuses for tribily monitoring systems # License: GPLv4 # Set Variables BKUP_DATE = '/bin/date + % Y % m % d' LOG = "/usr/local/zabbix/logs/nginx_status.log" HOST = "192.168.0.217" # HOST very important, make sure that CURL can access the StatusPORT = "80" # Functions to return nginx stats functionactive {/usr/bin/curl "http: // $ HOST: $ PORT/nginx_status "2>/dev/null | grep 'active' | awk '{print $ NF}'} functionreading {/usr/bin/curl" http: // $ HOST: $ PORT/nginx_status "2>/dev/null | grep 'reading' | awk '{print $2}'} functionwriting {/usr/bin/curl" http: // $ HOST: $ PORT/nginx_status "2>/dev/null | grep 'writing' | awk '{print $4}'} functionwaiting {/usr/bin/curl" http: // $ HOST: $ PORT/nginx_status "2>/dev/null | grep 'waiting' | awk '{print $6}'} functionaccepts {/usr/bin/curl" http: // $ HOST: $ PORT/nginx_status "2>/dev/null | awk NR = 3 | awk '{print $1}'} functionhandled {/usr/bin/curl" http: // $ HOST: $ PORT/nginx_status "2>/dev/null | awk NR = 3 | awk '{print $2}'} functionrequests {/usr/bin/curl" http: // $ HOST: $ PORT/nginx_status "2>/dev/null | awk NR = 3 | awk '{print $3}'} # Run the requested function $1
3. create a Templates App Nginx template on the Zabbix Web interface
(1) create three items first. the store value must change every second.
- Nginx. accepts
- Nginx. handled
- Nginx. requests
Here is an example: add nginx to the template. itemName nginx of accepts. accepts Type Zabbix agentKey nginx. acceptsTypeof information Numeric (unsigned) Data Type DecimalUnits empty Store value Detal (speed per second) Show value As is
(2) the last four item Store values remain unchanged.
- Nginx. connections. active
- Nginx. connections. reading
- Nginx. connections. writing
- Nginx. connections. waiting
Name nginx. connections. activeType Zabbix agentKey nginx. acceptsTypeof information Numeric (unsigned) Data Type DecimalUnits empty Store value As isShow value As is
This is probably the case after creation. I believe new users can do it too !!!
4. click the Graphs to be Tempates to create two Graphs.
Monitor Nginx (nginx. accepts, nginx. handled, nginx. requests) monitors Nginx (nginx. connections. active, nginx. connections. reading, nginx. connections. writing, nginx. connections. waiting)
Image 1: named Nginx_Interactive
Image 2: named Nginx_Connection
5. Hosts-Templates-link the created Templates App Nginx to the host
This is what it looks like after it is done.
6. create a Screen for Nginx monitoring in Screen and add the two images created earlier to the Screen
7. check the Nginx status on the Zabbix Web page ~~~
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.
The above introduces Zabbix monitoring Nginx, including some content, and hope to be helpful to friends who are interested in PHP tutorials.