[Zabbix30] Add nginx monitor Zabbix get Zabbix client Installation Grafana Zabbi

Source: Internet
Author: User
Tags grafana

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

Agent side

System is centos6.x, Zabbix-agent is version 3.0, nginx1.9.x official version

First to check if Nginx installed the http_stub_status_module module, the following command can see the compilation parameters.

-V

If you do not have this module, you will need to recompile the nginx.

Configure Nginx

The server configuration of Nginx 80 port adds the following fragment

location /nginx_status {        stub_statuson;        access_logoff;        allow127.0.0.1;        deny all;    }

After the configuration is complete, redload nginx, then use the simple test

>> curl http://127.0.0.1/nginx_status7server2707270712528016?

Zabbix-agent Configuration

There are 3 steps, the first is to write a script to get nginx information, then add the key information in the configuration, and then restart the agent service.

    • Write Nginx monitoring script, remember the path, the later configuration needs to use.

!! Note The script permissions issue, the agent runs the user to be able to execute.

>># mkdir-p/usr/local/zabbix-agent/scripts>># cd/usr/local/zabbix-agent/scripts>># vim nginx-check.sh>># cat Nginx-check.sh#!/bin/bash################################### Zabbix Monitoring script## Nginx:#-Anything available via Nginx stub-status module#################################### Contact:# vincent.viallet@gmail.com# Zabbix requested parameterZbx_req_data="$"Zbx_req_data_url="$"# Nginx DefaultsNginx_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_wr> "-0.9902"Error_data=" -0.9903"# either can not Connect/bad Host/bad port# Handle Host and port if Non-defaultif[!-Z"$ZBX _req_data_url"]; ThenUrl="$ZBX _req_data_url"ElseUrl="$NGINX _status_default_url"fi# Save the Nginx stats in a variable for future parsingnginx_stats=$ ($WGET _bin-Q$URL-O-2>/dev/null)# Error during retrieveif[ $?-ne0-o-z"$NGINX _stats"]; ThenEcho$ERROR _dataExit1fi## Extract data from Nginx stats# Case$ZBX _req_datainchActive_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' ';; ReadingEcho"$NGINX _stats"| Tail-1| Cut- F2- D' ';; WritingEcho"$NGINX _stats"| Tail-1| Cut- F4- D' ';; Waiting)Echo"$NGINX _stats"| Tail-1| Cut- F6- D' ';; *)Echo$ERROR _wrong_param;Exit1;;EsacExit0
    • The agent's configuration file /etc/zabbix/zabbix_agentd.conf defines the inclusion directory for other keys Include=/etc/zabbix/zabbix_agentd.d/ , and if not, add it yourself. Then /etc/zabbix/zabbix_agentd.d/ create a new file in the table nginx-params.conf of contents as follows
"$1"
    • Restart Agent
/etc/init.d/zabbix-agent restart

Web side of Server

First of all, the command line test agent is not good, confirm the use of the web-side after the template import, then you can add monitoring to the corresponding host.

>>>-s127.0.0.1-p10050-k"nginx[reading]"0

Login to the Web interface of Zabbix3.0, select > at a time, Configuration Templates There is a button in the upper right corner of the main interface Import to import the template.

Template file Compare long leave a download address

After the import, you can add monitoring to the host.

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the [Zabbix30] add nginx monitoring, including the zabbix,nginx aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • Related Article

    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.