Monitor nginx status with Zabbix

Source: Internet
Author: User

First Nginx To configure the Enable status


First, place the monitoring script on the client:

cat/etc/zabbix/monitor_scripts/nginx_status.sh //path name optional, specify this script when configuring Userparameter

#!/bin/bashhost=127.0.0.1port= " # functions to return nginx statsfunction"  active {/usr/bin/curl  "/http: $HOST $PORT/nginx-status"  2>/dev/null| grep  " Active '  | awk  ' {print  $NF} '} function reading {/usr/bin/curl  ' http://$ HOST: $PORT/nginx-status " 2>/dev/null| grep  ' Reading '  | awk  ' {print $2} '}  function writing {/usr/bin/curl  "http:/$HOST $PORT/nginx-status"  2>/dev/null|  grep  ' Writing '  | awk  ' {print $4} '} function waiting {/usr/bin/ curl  "/http $HOST: $PORT/nginx-status"  2>/dev/null| grep  ' Waiting '  | awk   ' {print $6} '} function accepts {/usr/bin/curl  '/http $HOST: $PORT/nginx-status "  2>/dev/null| awk NR==3 | awk  ' {print $1} '} function handled  {/usr/bin/curl  "http:/$HOST $PORT/nginx-status " 2>/dev/null| awk NR==3 | awk " {print $2 } '} function requests {/usr/bin/curl  '/http $HOST: $PORT/nginx-status " 2>/dev/null | awk nr==3 | awk  ' {print $3} '} # run the requested  Function$1


Second, configure the Zabbix client:

Configure zabbix_agentd.conf, make Unsafeuserparameters=1 //This does not seem necessary, I tried 0 or comments can

Then add a monitoring configuration in two ways:

1. Modify the zabbix_agentd.conf file

2. Open the Include file Include=

Add the following configuration

Userparameter=nginx.accepts,/bin/bash/etc/zabbix/monitor_scripts/nginx_status.sh acceptsUserParameter= Nginx.handled,/bin/bash/etc/zabbix/monitor_scripts/nginx_status.sh handleduserparameter=nginx.requests,/bin/ Bash/etc/zabbix/monitor_scripts/nginx_status.sh requestsuserparameter=nginx.connections.active,/bin/bash/etc/ Zabbix/monitor_scripts/nginx_status.sh activeuserparameter=nginx.connections.reading,/bin/bash/etc/zabbix/ Monitor_scripts/nginx_status.sh Readinguserparameter=nginx.connections.writing,/bin/bash/etc/zabbix/monitor_ Scripts/nginx_status.sh writinguserparameter=nginx.connections.waiting,/bin/bash/etc/zabbix/monitor_scripts/ Nginx_status.sh Waiting


Three: In the Zabbix Web Import configuration template (attachment, the Internet to find drops)


Note: Ensure that the zabbix_agentd.conf hostname configuration is correct, many articles on the internet did not mention this, at first I also did not notice, resulting in the configuration is not monitored, no data collected

Monitor nginx status with Zabbix

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.