Zabbix monitoring Nginx

Source: Internet
Author: User
Zabbix monitoring Nginx

Before adding monitoring, it must be emphasized that Nginx must support stub_status state access, otherwise everything is empty talk!!!

--with-http_stub_status_module例如:.--user=--group=--prefix=/usr/local--with-http_stub_status_module--with-http_ssl_module
在Nginx配置档中添加:     location /nginx_status {                on;                access_log   off;                }

First, create the key to monitor Nginx

    • Nginx_status_key
  vim/usr/local/zabbix/etc/zabbix_agentd . conf  . D /nginx_status_keyuserparameter=nginx . Accepts ,/usr/local/zabbix/shell/nginx_status . Sh  accepts Userparameter=nginx . Handled ,/usr/local/zabbix/shell/nginx_status . SH  Handled Userparameter=nginx . Requests ,/usr/local/zabbix/shell/nginx_status . SH  Requests Userparameter=nginx . Connections  . Active ,/usr/local/zabbix/shell/nginx_status . Sh  active Userparameter=nginx . Connections  . Reading ,/usr/local/zabbix/shell/nginx_ Status . sh  reading Userparameter=nginx . Connections  . Writing ,/usr/local/ Zabbix/shell/nginx_status . Sh  writing Userparameter=nginx . Connections  . Waiting ,/usr/local/zabbix/shell/nginx_status . Sh  waiting  

II. create a script to monitor nginx (remember to add execute permission)

    • nginx_status.sh
vim/usr/local/zabbix/shell/nginx_status.sh#!/bin/Bash # Script to fetch nginx statuses fortribily Monitoring Systems # license:gplv4 # Set Variables bkup_date= '/bin/date +%y%m%d ' log="/usr/local/zabbix/logs/nginx_status.log"host="192.168.0.217"#HOST非常重要, make sure that curl can access the IP address of the statusport="a"# Functions toreturnNginx Stats functionactive {/usr/bin/curl"/http $HOST: $PORT/nginx_status"2>/dev/NULL| Grep' Active '| Awk' {print $NF} '} functionreading {/usr/bin/curl"/http $HOST: $PORT/nginx_status"2>/dev/NULL| Grep' Reading '| Awk' {print $} '} functionwriting {/usr/bin/curl"/http $HOST: $PORT/nginx_status"2>/dev/NULL| Grep' Writing '| Awk' {print $4} '} functionwaiting {/usr/bin/curl"/http $HOST: $PORT/nginx_status"2>/dev/NULL| Grep' Waiting '| Awk' {print $6} '} functionaccepts {/usr/bin/curl"/http $HOST: $PORT/nginx_status"2>/dev/NULL| awk nr==3| Awk' {print '} '} functionhandled {/usr/bin/curl"/http $HOST: $PORT/nginx_status"2>/dev/NULL| awk nr==3| Awk' {print $} '} functionrequests {/usr/bin/curl"/http $HOST: $PORT/nginx_status"2>/dev/NULL| awk nr==3| Awk' {print $} '} # Run The requested function  $

Third, create the Templates App nginx template in the Zabbix Web interface
(1), first create three item, this store value requires a change per second

    • Nginx.accepts
    • Nginx.handled
    • Nginx.requests
我在这边做一个示例:模版中添加一个nginx.accepts的itemName                nginx.accepts  Type                Zabbix agentKey                 nginx.acceptsTypeof information Numeric (unsignedType           DecimalUnits               空Store value         Detal (speed per second)Show  value         is

(2), then four item Store value is unchanged

    • Nginx.connections.active
    • Nginx.connections.reading
    • Nginx.connections.writing
    • Nginx.connections.waiting
Name                nginx.connections.activeType                Zabbix agentKey                 nginx.acceptsTypeof information Numeric (unsignedType           DecimalUnits               空Store value         isShow  value         is

After the creation is probably this appearance, believe the novice also can make out!!!

Four, now click on the graphs to tempates, create two graphs

监控Nginx(nginx.accepts、nginx.handled、nginx.requests)监控Nginx(nginx.connections.active、nginx.connections.reading、nginx.connections.writing、nginx.connections.waiting)

Image 1: The name nginx_interactive

Image 2: The name nginx_connection

V. hosts-templates-link the Templates App you just created to the host
That's probably what it's like when you're done.

VI. Create a monitor screen in screen to add the two images created earlier

Seven, this time in the Zabbix Web page to view the Nginx state is ok~~~

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The above describes the Zabbix monitoring nginx, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.