How does Zabbix implement Nginx monitoring ?, Zabbix monitors nginx
The stub_status module is required for Nginx to be monitored by Zabbix. This module needs to be loaded first because it is not installed during source code compilation and installation.
1. View nginx installation Configuration
Cd/usr/local/nginx/sbin /. /nginx-Vnginx version: nginx/1.4.2built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) tls sni support enabledconfigure arguments: -- prefix =/usr/local/nginx -- with-http_ssl_module -- with-pcre =/home/package/pcre-8.35 -- with-zlib =/home/package/zlib-1.2.8 -- with-openssl =/home /package/openssl-1.0.1g to enter the nginx decompression folder. /configure -- prefix =/usr/local/nginx -- The with-http_ssl_module -- with-pcre =/home/package/pcre-8.35 -- with-zlib =/home/package/zlib-1.2.8 -- with-openssl = /home/package/openssl-1.0.1g ** -- with-http_stub_status_module (add this in original configuration) **......
Make
Do not make install
Directly replace the nginx file in objs with the nginx file in the original sbin (of course, it is best to back up the original, so that the problem can be restored)
2.
First, touch a status in nginx and check it through webpage access. The content is: Active connections: 1 server accepts handled requests 20 5 9 Reading: 0 Writing; 1 Waiting: 0 [root @ server2] # cd/etc/zabbix/zabbix_agentd.d/[root @ server2 zabbix_agentd.d] # vim nginx. confUserParameter = nginx. active, curl-s http: // 192.168.137.102/status | grep Active | awk '{print $ NF}' # monitored nginxIP address UserParameter = nginx. server, curl-s http: // 127.0.0.1/status | awk N R = 3 | awk '{print $1}' # obtain the first character UserParameter = nginx In the third line of status. accept, curl-s http: // 127.0.0.1/status | awk NR = 3 | awk '{print $2}' UserParameter = nginx. handled, curl-s http: // 127.0.0.1/status | awk NR = 3 | awk '{print $3}' [root @ server2 zabbix_agentd.d] #/etc/init. d/zabbix-agent restart [root @ server2 zabbix_agentd.d] # vim/usr/local/nginx/conf/nginx. conf location/{root html; index index.html index. h Tm;} location/tatus {stub_status on; access_log off;} [root @ server2 ~] # Nginx-t [root @ server2 ~] # Nginx-s reload
# Server test whether data can be obtained [root @ Server3 ~] # Zabbix_get-s 192.168.137.102-k nginx. server20 [root @ Server3 ~] # Zabbix_get-s 192.168.137.102-k nginx. accept5 [root @ Server3 ~] # Zabbix_get-s 192.168.137.102-k nginx. handled9
3. Add metric items and create images