Zabbix monitoring Nginx

Source: Internet
Author: User
Tags nginx host

First, open the Nginx_status page

server {\ \ \ defines a virtual host listen default_server;   \ \ Definition Listening Address server_name _;   \ \ define Hostname location =/ngx_status {stub_status on;    \ \ Open status Access_log off;   \ \ Close Access log allow 127.0.0.1;       \ Do access control deny all; }


Second, write the shell script to get ngx_status page data (file path is zabbix/script/nginx_status.sh)

#!/bin/bashactive () {        wget --quiet -o - http ://127.0.0.1/ngx_status |awk  ' nr==1 {print$3} '}accepts () {         wget --quiet -O - http://127.0.0.1/ngx_status |awk  ' nr==3 { print$1} '}handled () {        wget --quiet -o - http ://127.0.0.1/ngx_status |awk  ' nr==3 {print$2} '}requests () {         wget --quiet -O - http://127.0.0.1/ngx_status |awk  ' nr==3 { Print$3} '}reading () {        wget --quiet -o - http ://127.0.0.1/ngx_status |awk  ' nr==4 {print$2} '}writing () {         wget --quiet -O - http://127.0.0.1/ngx_status |awk  ' nr==4 { print$4} '}waiting () { &Nbsp;      wget --quiet -o - http://127.0.0.1/ngx_status  |awk  ' nr==4 {print$6} '}$1


Iii. define the key used when Zabbix gets data: (path:/opt/zabbix/etc/zabbix_agentd.conf.d/userparameter_nginx_status.conf)

Userparameter=nginx.accepts,/opt/zabbix/script/nginx_status.sh acceptsuserparameter=nginx.handled,/opt/zabbix/ Script/nginx_status.sh handleduserparameter=nginx.requests,/opt/zabbix/script/nginx_status.sh Requestsuserparameter=nginx.connections.active,/opt/zabbix/script/nginx_status.sh ActiveUserParameter= Nginx.connections.reading,/opt/zabbix/script/nginx_status.sh readinguserparameter=nginx.connections.writing,/ Opt/zabbix/script/nginx_status.sh readinguserparameter=nginx.connections.waiting,/opt/zabbix/script/nginx_ Status.sh Waiting


Four, restart ZABBIX_AGETD service

/etc/init.d/zabbix_agentd restart


V. Using Zabbix_get to check if data can be obtained

Zabbix_get-s 192.168.74.132-p 10050-k nginx.accepts2194751016


Vi. Making Templates

Configuring----> Creating a template----> Creating an app set-------> Creating a project (adding a key to get data in a project)----> Creating a drawing

To create a project:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7D/E4/wKiom1byOZCgEp2rAAEEmonQcIM689.png "title=" 2.png " alt= "Wkiom1byozcgep2raaeemonqcim689.png"/>

All items:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7D/E1/wKioL1byOk-S-FXXAACvbvoZ0ag283.png "title=" 3.png " alt= "Wkiol1byok-s-fxxaacvbvoz0ag283.png"/>

To add a graphic:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7D/E1/wKioL1byOsjgEOqkAADdOPEFGY8430.png "title=" 4.png " alt= "Wkiol1byosjgeoqkaaddopefgy8430.png"/>

Seven, the production of a good template to the Nginx host, get the data as follows:


650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7D/E1/wKioL1byO0TD3mW4AAEELUjQyXg912.png "title=" 5.png " alt= "Wkiol1byo0td3mw4aaeelujqyxg912.png"/>

To this, Zabbix monitoring Nginx has been built to complete

This article is from the "Trot Empty" blog, be sure to keep this source http://jingfu.blog.51cto.com/6184921/1754266

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.