Zabbix monitoring Nginx

Source: Internet
Author: User
Tags nginx server

On the Zabbix agentd client, check to see if Nginx has loaded the--with-http_stub_status_module.

Enable the Stubstatus module, add parameters when compiling Nginx

--with-http_stub_status_module

1. In the Nginx configuration file, add the status configuration.

Location/nginx_status {stub_status on;  Access_log off;  Allow 127.0.0.1;  Allow 192.168.1.10;       # (IP address of Zabbix server, usually intranet address) deny all; }


2. Access the set Nginx _ status link,:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/D0/wKioL1cuusiCd1EFAAAguHFidvo346.png "title=" Picture 1.png "alt=" Wkiol1cuusicd1efaaaguhfidvo346.png "/>

3.nginx Status Detailed Description:

Activeconnections: The number of active connections initiated on the backend;

Server accepts 782743 : Nginx has processed a total of 782743 a connection;

handled: Successful creation of 3108800 second handshake;

requests: Total processing 180152701 request.

Reading:nginx read the number of headers of the client;

Writing:nginx the number of headers returned to the client;

Waiting:nginx request processing completed, waiting for the next request instruction connection.

4. Write the script to monitor Nginx on Agentd, and set the owner and the group as Zabbix, give execute permission.

Cd/usr/local/zabbix/scripts

cat nginx_status.sh      

#!/bin/bash# script to fetch nginx statuses for tribily monitoring  systems# author: [email protected]bkup_date= '/bin/date +%y%m%d ' LOG= "/data/log/zabbix /webstatus.log "host=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


chmod  + x nginx_status. SH

chown   –   .  

5. Modify the zabbix_agentd.conf configuration file for the Zabbix client on the Nginx server, and then restart the Zabbix agentd client.

Cd/usr/local/zabbix/etc

Grep-v "^[#;]" zabbix_agentd.conf | Grep-v the IP address of the server side of the "^$" logfile=/usr/local/zabbix/logs/zabbix_agentd.logserver=192.168.1.10 #zabbix serveractive=1 92.168.1.10 #zabbix server-side IP address hostname=192.168.1.11 #本地的IP地址UnsafeUserParameters =1
# #下面的是新添加进去的UserParameter =nginx.accepts,/usr/local/zabbix/scripts/nginx_status.sh accepts userparameter= Nginx.handled,/usr/local/zabbix/scripts/nginx_status.sh handled userparameter=nginx.requests,/usr/local/zabbix/ scripts/nginx_status.sh Requests Userparameter=nginx.connections.active,/usr/local/zabbix/scripts/nginx_  status.sh Active userparameter=nginx.connections.reading,/usr/local/zabbix/scripts/nginx_status.sh Reading userparameter=nginx.connections.writing,/usr/local/zabbix/scripts/nginx_status.sh Writing UserParameter= Nginx.connections.waiting,/usr/local/zabbix/scripts/nginx_status.sh Waiting


6. The Zabbix_get test on the Zabbix server side, the data is taken, the explanation is no problem.

#/usr/local/zabbix/bin/zabbix_get-s 10.172.164.244-p 10050-k "Nginx.connections.active" 11#/usr/local/zabbix/bin/ Zabbix_get-s 10.172.164.244-p 10050-k "nginx.connections.waiting" 10#/usr/local/zabbix/bin/zabbix_get-s 10.172.164.244-p 10050-k "nginx.connections.writing" 1#/usr/local/zabbix/bin/zabbix_get-s 10.172.164.244-p 10050-k " Nginx.accepts "2350638#/usr/local/zabbix/bin/zabbix_get-s 10.172.164.244-p 10050-k" Nginx.requests "8801086


7. Zabbix the template of Nginx status, import the template into the Zabbix server.

See Attachment!

8. Login to Zabbix Server homepage, click "Configure"-"template" - Click on the " Guide into the file, and then put the found Nginx_status.xml file, Guide into the template.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7F/D0/wKioL1cuutajktVAAACEgI4F_Z0604.png "title=" Picture 2.png "alt=" Wkiol1cuutajktvaaacegi4f_z0604.png "/>

Add Host

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/D3/wKiom1cuugXDIFCwAABq3J6dNFk808.png "title=" Picture 3.png "alt=" Wkiom1cuugxdifcwaabq3j6dnfk808.png "/>

Association templates

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7F/D0/wKioL1cuuu7R7XZ5AABdQ1AkdtU183.png "title=" Picture 4.png "alt=" Wkiol1cuuu7r7xz5aabdq1akdtu183.png "/>

Add to

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7F/D0/wKioL1cuuvnwjqJWAABYm58b22E005.png "title=" Picture 5.png "alt=" Wkiol1cuuvnwjqjwaabym58b22e005.png "/>

Finally, see if the data can be detected, whether it can be successfully out of the diagram.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7F/D0/wKioL1cuuxDxKdPDAABeR12qrE0170.png "title=" Picture 6.png "alt=" Wkiol1cuuxdxkdpdaaber12qre0170.png "/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7F/D3/wKiom1cuuj6R47bnAABtJ-3lG9c810.png "title=" Picture 7.png "alt=" Wkiom1cuuj6r47bnaabtj-3lg9c810.png "/>


This article is from the "Stop fighting = Stop Life" blog, make sure to keep this source http://53cto.blog.51cto.com/9899631/1771172

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.