Work notes for zabbix monitoring nginx

Source: Internet
Author: User
Tags stub unsupported

Principle: zabbix monitors nginx based on the nginx Stub Status module, captures the data of the Stub Status to provide nginx, and then splits
First, check whether http_stub_status_module is installed in nginx.
Run the following command to check the rpm installation:

Nginx-V
Run the following command to check the source code installation:

/Usr/local/nginx/sbin/nginx-V
I have installed rpm here, please refer to the figure

Nginx check http_stub_status_module

If it is not installed, find the nginx smooth addition module on the Internet.

The agent starts configuring nginx_status.

Add nginx configuration

Vi/usr/local/nginx/conf/nginx. conf
Location/nginx_status
{
Stub_status on;
Access_log off;
Allow 127.0.0.1;
Allow 192.168.171.22; # (the IP address of the zabbix server, which is generally an intranet address, can also be left empty)
Deny all;
}
Put the above code in the server with ip access
This code does not need to be modified for nginx.
Access through ip address
Http: // 192.168.171.22/nginx_status

View my access results

Nginx_status

Explain the above results
Active connections: 2 # Number of Active connections initiated to the backend
Server accepts # nginx processes a total of 23 connections
Handled #23 handshakes created successfully
Requests #120 requests processed in total
Reading: 0 # Number of headers that nginx reads from the client
Writing: 1 # Number of headers nginx returns to the client
Waiting: 1 # nginx request processing is complete, Waiting for the connection of the next request command

Add an nginx monitoring script for agentd

The content of the script is the result split of accessing http: // 192.168.171.22/nginx_status.
I shared the script content.
Nginx_status.sh
This script is stored in the/etc/zabbix/scripts/directory.

Nginx_status.conf

Put it in the agent configuration directory or in the agent configuration file.

I put it in the/etc/zabbix/zabbix_agentd.d Directory (recommended)

You can also put it in/etc/zabbix/zabbix_agentd.conf.
Test it on the server.

Zabbix_get-s 192.168.171.22-k custom. nginx. connections. waiting
ZBX_NOTSUPPORTED: Unsupported item key. Error Found

ZBX_NOTSUPPORTED: Unsupported item key
Open
Vi/etc/zabbix/zabbix_agentd.conf
Modify the UnsafeUserParameters parameter to 1.
UnsafeUserParameters = 1

Restart the agent server.

Service zabbix-agent restart
In execution

Zabbix_get-s 192.168.171.22-k custom. nginx. connections. waiting
Found
Sh:/etc/zabbix/scripts/nginx_status.sh: insufficient permissions

Insufficient permissions
Modify the permissions of nginx_status.sh.

Chmod 755/etc/zabbix/scripts/nginx_status.sh
The test succeeds.

Import the template to the zabbix web client

 


Then use this template
Monitoring chart
Add a group if you do not know.

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.