Zabbix Monitoring Nginx Connection Status

Source: Internet
Author: User

Zabbix Study notes: Zabbix monitoring Nginx Connection Status


Zabbix monitoring Nginx

Zabbix can monitor the status of Nginx, about the status of a service can see the status of the service itself (version number, whether Open), but also should focus on service capabilities (such as the load effect of Nginx: number of connections , number of requests and handle number ). Below we use Zabbix to monitor nginx.

Installation of Nginx

If you want to view Nginx service status, the –with-http_stub_status_module module should be selected when installing the Nginx source code.

1. Unpack the installation package :

[Email protected] mnt]# tar xvf nginx-1.6.2.tar.gz

2. Configure the module in the installation directory :
650) this.width=650; "src=" http://img.blog.csdn.net/20151230160739268 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

3. options for installing the configuration :
650) this.width=650; "src=" http://img.blog.csdn.net/20151230160823574 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

Manually collecting Nginx data

After installation, in the Nginx installation directory (the default is /usr/local/nginx) We need to modify the Nginx main configuration file, if Nginx can support the display of status information can be viewed in Nginx version:

1. See if the module is installed successfully:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230161054837 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

You can see that you already have the –with-http_stub_status_module module.

2. Modify the configuration file /usr/loca/nginx/conf/nginx.confto add the specified Server service in the HTTP section:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230161353329 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

Note: Configure only allow 192.168.1.0/24 network segment people to view nginx status, other network segments of people can not view.

3. After the modification is completed, the Nginx service is started and the /usr/local/nginx/sbin/nginx file can be set up in a soft link to the /usr/bin/ directory for convenient period:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230161710985 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

4. Open Nginx Service:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230161737126 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

5. Use the command to collect the status information of Nginx:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230161848129 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

6. The above information includes read, write wait, and number of connections, requests, etc., we need to write script information to be collected separately. The script contents are as follows:

#get_nginx_status. Sh#nginx Information Acquisition Script #!/bin/bash# setting initialization information nginx_server= "192.168.1.108" nginx_url= "http://${nginx_ Server}/status "#设置采集信息的方式function  get_active {    curl -s ${nginx_url}  | grep  "Active"  | awk -F  ":"   ' {print $2} '}function get_ reading {    curl -s ${nginx_url} | grep  "reading"  |  awk -F  ":"   ' {print $2} '  | awk -F  " "   ' {print $1} ' }function get_writing {    curl -s ${nginx_url} | grep  "Writing"  | awk -F  ":"   ' {print $3} '  | awk -F  '   '   ' {print $1} '}function get_waiting {    curl -s ${nginx_url} |  grep  "Waiting"  | awk -F  ":"   ' {print $4} '  | awk -f   " "   ' {print $1} '}function get_accepts {    curl -s ${nginx_url} |  awk nr==3 | awk -f  " "   ' {print $1} '}function get_handled {     curl -s ${nginx_url} | awk nr==3 | awk -f   " "   ' {print $2} '}function get_requests {    curl -s  ${NGINX_URL} | awk NR==3 | awk -F  " "   ' {print $3} '}# Get the input parameter of the user to get the corresponding value case $1 in     active)           get_active         ;;     reading)          get_reading          ;;     writing)          get_writing              ;;     waiting)          get_waiting          ;;     accepts)          get_accepts           ;;     handled)          get_handled          ;;     requests)          get_requests              ;;     *)          echo  "usage: $0  {active | reading | writing | waiting | accepts |  Handled | requests} "esac1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 

7. After completing the script and testing, you need to modify the /etc/zabbix/zabbix-agentd.conf file to add the corresponding userparameter:

650) this.width=650; "src=" http://img.blog.csdn.net/20151230230526530 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

8. Restart the Zabbix-agent service on the client:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230230647591 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

9. Use the Zabbix_get command on the server side to test to see if the data can be obtained smoothly, if the operation can be performed, indicating that the acquisition status is normal:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230231757954 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

We have randomly tested four data here and found it to be normal.

Monitoring items added to Zabbix items

If the data collection is not a problem, then you can add items to the Web console.
650) this.width=650; "src=" http://img.blog.csdn.net/20151230231938950 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

Let's take nginx.active for example, other similar operations:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230232051916 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

You can see that the items you need are already generated, and these items are part of Nginx's application:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230232514894 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

Generate graphs

We can visualize the service status of Nginx (generate the corresponding graphs):
650) this.width=650; "src=" http://img.blog.csdn.net/20151230232700831 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

Create screen to display multiple graphs:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230232835771 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

The screens of the Nginx condition state that created the agent1.example.com node is complete:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230233057780 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

You can see the accpets, requests, handled status of Nginx:
650) this.width=650; "src=" http://img.blog.csdn.net/20151230233144542 "alt=" here write a picture describing "title=" "style=" border:none; "/ >

Summary:

Using Zabbix is similar to the monitoring steps for a service:
1. First to obtain the status of the service manually;
2. Then write the script to get it automatically and then write to the agent's/etc/zabbix/zabbix-agentd.conf file
3. The monitoring server zabbix-server the relevant acquisition test, if successful, the Web interface for the monitoring of items and graphs.


This article is from the "Null" blog, so be sure to keep this source http://kongshuai.blog.51cto.com/10178307/1737193

Zabbix Monitoring Nginx Connection Status

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.