Using Zabbix to monitor Nginx

Source: Internet
Author: User
Tags curl
If there is data return, the Zabbix communication is normal, if return zbx_notsupported, it indicates that there is a problem with the monitor. Enter the system configuration-> host-> Monitor to see if your client host's monitor is active or not, and you must reboot after configuring Agentd. /usr/local/webserver/zabbix/bin/zabbix_get-s 192.168.0.253-p10050-k "Nginx.accepts"


I have been using Zabbix for a long time to monitor more things, and I am now in the first step to achieve the original plan. It has to be said that its free customization function is really strong. Let's get started.

Implementing monitoring requires three steps:

1. Create or import templates yourself. < accessories >

2, Nginx need to configure status.

This is because of the environment, I put on my bar.

server {Listen 80; server_name xxx.baidu.com;   Index index.html login.jsp;   Root/www/freetrade;   Access_log off;   Error_log off;   Location/nginx {stub_status on;   Access_log off;  Allow 127.0.0.1;   #服务端IP allow xxx.xxx.xxx.xxx;   Deny all; }   }

3, change the client configuration file, use the script.

Place the script anywhere on the client machine, but I suggest you put it in one place. I changed it on the basis of the author to suit my needs.

#!/bin/bash   # script to fetch nginx statuses for tribily  monitoring systems   # author: krish@toonheart.com   # License:  gplv2    # set variables   host= "xxx.baidu.com" port= "no"     #  functions to return nginx stats    function Active { /usr/bin/curl-s  http ://$HOST: $PORT "| grep ' Active ' | awk ' {print $NF} '  } function reading { /usr/bin/curl-s  ' http://$HOST: $PORT ' | grep ' reading ' | awk ' { Print $} '  } function writing { /usr/bin/curl-s  ' http://$HOST: $PORT ' | grep ' writing ' | awk ' {print $ 4} '  } function waiting { /usr/bin/curl-s  ' http://$HOST: $PORT ' | grep ' waiting ' | awk ' {print $} ' &NB Sp function accepts { /usr/bin/curl-s  "http://$HOST: $PORT" | awk nr==3 | awk ' {print} '  } function h andled { /usr/bin/curl -s  "http://$HOST: $PORT" | awk nr==3 | awk ' {print $} '  } function requests { /usr/bin/curl-s  ' http://$HOST: $PORT ' | awk nr==3 | awk ' {PRINT $} '  }   # run the requested function   $1 

Modify client/etc/zabbix/zabbix_agentd.conf environment, file location is different.

#monitor Nginx Userparameter=nginx.accepts,/etc/zabbix/scripts/nginx_status accepts userparameter=nginx.handled,/   Etc/zabbix/scripts/nginx_status handled Userparameter=nginx.requests,/etc/zabbix/scripts/nginx_status requests Userparameter=nginx.connections.active,/etc/zabbix/scripts/nginx_status Active userparameter= Nginx.connections.reading,/etc/zabbix/scripts/nginx_status Reading userparameter=nginx.connections.writing,/etc/ Zabbix/scripts/nginx_status Writing Userparameter=nginx.connections.waiting,/etc/zabbix/scripts/nginx_status Waiting

There is a picture to the truth. < several free nginx>


Related Accessories Download

free download address in http://linux.linuxidc.com/

username and password are www.linuxidc.com

download Directory in /2012/7/9th/Use Zabbix monitoring nginx/

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.