zabbix3.0.4 Monitoring Nginx Service

Source: Internet
Author: User

Zabbix3.0.4 adding monitoring for nginx services

One

Through the Nginx http_stub_status_module module provides the status information to monitor, so in the agent side need to configure the Nginx state to obtain the script, and add key information, and then configure the server side of the Nginx monitoring template. Please adjust according to your own situation, here is only a simple reference.


The main use of GitHub is the code for this project Zabbix-templates

Check if Nginx has the Http_stub_status_module module installed, the following command can see the compilation parameters.

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8B/7A/wKioL1hPhYHglR7MAAAtrHSR7Ks403.png-wh_500x0-wm_3 -wmp_4-s_2143917663.png "title=" 1.png "alt=" Wkiol1hphyhglr7maaatrhsr7ks403.png-wh_50 "/>

If you do not have a http_stub_status_module module, recompile and add the module

Two

Configure Nginx as

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/8B/7A/wKioL1hPhmGxRPy6AAAiknoq4fs551.png-wh_500x0-wm_3 -wmp_4-s_3270727814.png "title=" 2.png "alt=" Wkiol1hphmgxrpy6aaaiknoq4fs551.png-wh_50 "/>

Restart Nginx/usr/local/nginx/sbin/nginx-s Reload

See below

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/8B/7A/wKioL1hPhzXCYkJxAAAY5O5af4g275.png-wh_500x0-wm_3 -wmp_4-s_2068059108.png "title=" 3.png "alt=" Wkiol1hphzxcykjxaaay5o5af4g275.png-wh_50 "/>

Three

1.nginx Script Cat nginx-check.sh

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/8B/7A/wKioL1hPiBawvImyAACl7_WNdSo621.png-wh_500x0-wm_3 -wmp_4-s_145725426.png "title=" 4.png "alt=" Wkiol1hpibawvimyaacl7_wndso621.png-wh_50 "/>

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/8B/7D/wKiom1hPiBaBGP1JAABHB9wBbYY809.png-wh_500x0-wm_3 -wmp_4-s_3968481270.png "title=" 5.png "alt=" Wkiom1hpibabgp1jaabhb9wbbyy809.png-wh_50 "/>

#!/bin/bash
##################################
# Zabbix Monitoring Script
#
# Nginx:
#-Anything available via Nginx stub-status module
#
##################################
# Contact:
# [Email protected]
# Zabbix Requested parameter
Zbx_req_data= "$"
Zbx_req_data_url= "$"
# Nginx Defaults
Nginx_status_default_url= "Http://127.0.0.1/nginx_status"
Wget_bin= "/usr/bin/wget"
#
# Error Handling:
#-Need to being displayable in Zabbix (avoid not_supported)
#-Items need to is of type "float" (allow negative + float)
#
error_no_access_file= "-0.9900"
error_no_access= "-0.9901"
error_wrong_param= "-0.9902"
Error_data= " -0.9903" # either can not Connect/bad Host/bad port
# Handle host and Port if Non-default
if [!-Z "$ZBX _req_data_url"]; Then
Url= "$ZBX _req_data_url"
Else
Url= "$NGINX _status_default_url"
Fi
# Save the Nginx stats in a variable for future parsing
nginx_stats=$ ($WGET _bin-q $URL-O-2>/dev/null)
# Error during retrieve
If [$?-ne 0-o-Z "$NGINX _stats"]; Then
Echo $ERROR _data
Exit 1
Fi
#
# Extract data from Nginx stats
#
Case $ZBX _req_data in
Active_connections) echo "$NGINX _stats" | head-1 | cut-f3-d ';
Accepted_connections) echo "$NGINX _stats" | Grep-ev ' [a-za-z] ' | Cut-f2-d ';
Handled_connections) echo "$NGINX _stats" | Grep-ev ' [a-za-z] ' | cut-f3-d ';
handled_requests) echo "$NGINX _stats" | Grep-ev ' [a-za-z] ' | Cut-f4-d ';
Reading) echo "$NGINX _stats" | Tail-1 | Cut-f2-d ';
Writing) echo "$NGINX _stats" | Tail-1 | Cut-f4-d ';
Waiting) echo "$NGINX _stats" | Tail-1 | Cut-f6-d ';
*) echo $ERROR _wrong_param; Exit 1;;
Esac
Exit 0

Give script permission

chmod +x nginx-check.sh

2. The agent's configuration file/usr/local/zabbix-3.0.4/etc/zabbix_agentd.conf defines the inclusion directory for other keys include=/usr/local/zabbix-3.0.4/etc/ zabbix_agentd.d/, if you do not have this configuration, please add it yourself. Next, create a new file nginx-params.conf in the/usr/local/zabbix-3.0.4/etc/zabbix_agentd.d/directory, which reads as follows

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/8B/7D/wKiom1hPic-jU43fAAAlyMp02AU134.png-wh_500x0-wm_3 -wmp_4-s_70509079.png "title=" 6.png "alt=" Wkiom1hpic-ju43faaalymp02au134.png-wh_50 "/>

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8B/7A/wKioL1hPidCSXiuvAAAS18kCo6E072.png-wh_500x0-wm_3 -wmp_4-s_2974488708.png "title=" 7.png "alt=" Wkiol1hpidcsxiuvaaas18kco6e072.png-wh_50 "/>

Cat nginx-params.conf


Userparameter=nginx[*],/usr/local/zabbix-agent/scripts/nginx-check.sh "$"


3. Restart Zabbix_agent



Four

Server-Side Testing

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/8B/7D/wKiom1hPi6HhFEmVAAAbCowj4GE089.png-wh_500x0-wm_3 -wmp_4-s_4038815860.png "title=" 8.png "alt=" Wkiom1hpi6hhfemvaaabcowj4ge089.png-wh_50 "/>

Web Interface Import Template

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/8B/7A/wKioL1hPjImReDOjAABdkBxaXqo490.png-wh_500x0-wm_3 -wmp_4-s_3590239072.png "title=" 9.png "alt=" Wkiol1hpjimredojaabdkbxaxqo490.png-wh_50 "/>

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/8B/7A/wKioL1hPjIngR1GfAAAxxGzBKUQ604.png-wh_500x0-wm_3 -wmp_4-s_2694086031.png "title=" 10.png "alt=" Wkiol1hpjingr1gfaaaxxgzbkuq604.png-wh_50 "/>

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/8B/7D/wKiom1hPjInQ1QzrAABP_P0Aqqg052.png-wh_500x0-wm_3 -wmp_4-s_426956113.png "title=" 11.png "alt=" Wkiom1hpjinq1qzraabp_p0aqqg052.png-wh_50 "/>

Viewing monitoring on the web side

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/8B/7D/wKiom1hPjQLChyORAAClvJ7Ns2g138.png-wh_500x0-wm_3 -wmp_4-s_3703080882.png "title=" 12.png "alt=" Wkiom1hpjqlchyoraaclvj7ns2g138.png-wh_50 "/>









Note: template address Https://github.com/jizhang/zabbix-templates/blob/master/nginx/nginx-template.xml







zabbix3.0.4 Monitoring Nginx Service

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.