Zabbix (vi): Project Combat--automatic discovery Nginx Scheduler and backend Web service cluster, custom parameter monitoring

Source: Internet
Author: User

Project:

1. Automatically discover the Nginx scheduler and the backend Apache built Web services cluster;

2. Use custom parameters to monitor the data and rate of Nginx service on the scheduler;

3. Use custom parameters to monitor the relevant statistics and rate data of the back-end Apache Service (optional)

4. Develop a monitoring template for the Nginx Scheduler and the backend Apache service, defined in the template: Items, trigger, graph; (optional)


-------------------------------------------------------------------------------------------------------

Project planning:

Zabbix-server End: 172.16.1.2

Zabbix-agent-End/nginx Scheduler: 172.16.1.99

Zabbix-agent End/back end rs1:172.16.1.3

Zabbix-agent End/back end rs2:172.16.1.10


The Nginx Scheduler's IP address is set to a larger number, in order to set Zabbix Discovery, automatically distinguish between Nginx Scheduler and the backend Apache built Web services cluster, so the following can be set two Zabbix Discovery, Separate hosts for different roles are found.


1.

Zabbix-server End:

Install the following applications

Yum install zabbix-server-mysql zabbix-web-mysql zabbix-web zabbix-agent zabbix-get-y

For detailed server-side configuration, please refer to: http://blog.51cto.com/12667170/2044254


Three x Zabbix-agent end:

Install the following applications

Yum install-y zabbix-agent Zabbix-sender

For detailed agent-side configuration, please refer to: http://blog.51cto.com/12667170/2044254


2. Create Nginx Scheduler

Add upstream content to the HTTP segment in the nginx.conf configuration file, adding the back-end two RS to the upstream

Upstream ZRS {

Server 172.16.1.3;

Server 172.16.1.10;

}

server {

Listen 80;

Location/{

Proxy_pass Http://zrs;

Proxy_set_header X-real-ip $remote _addr;

}

}


Two rear-end RS each configured with one index.html for easy testing and open httpd service


The test can be seen using the Roundrobin mode for back-end RS access.

[[email protected] ~]# for i in {1..10}; Do Curl http://172.16.1.99; Done


3. Automatic discovery of Nginx Scheduler and backend Apache built Web services cluster


Creating Nginx Discovery


Create Web Discovery


Open the Zabbix-agent service on the Nginx scheduler side and back end RS host respectively

View hosts, which have been added to these three hosts


4. Use custom parameters to monitor the data and rate of Nginx service on the scheduler.


In order to monitor nginx status, add location monitor nginx status value in the server of Nginx main configuration file.


[Email protected] ~]# vim/etc/nginx/nginx.conf


Location/status {

Stub_status on;

}


[Email protected] ~]# systemctl restart Nginx.service

[Email protected] ~]# Curl 172.16.1.99/status

Active connections:1

Server accepts handled requests

1 1 1

reading:0 writing:1 waiting:0


Monitor nginx status, need item key, default No, need custom parameter userparameters


5. Custom parameters (Userparameters)


Nginx Custom Parameters

Vim/etc/zabbix/zabbix_agentd.d/userparameter_nginx.conf


Userparameter=nginx.active,curl-s Http://172.16.1.99/status | awk '/^active/{print $NF} '

Userparameter=nginx.accepts,curl-s Http://172.16.1.99/status | awk '/^[[:space:]]+[0-9]/{print \ '

Userparameter=nginx.handled,curl-s Http://172.16.1.99/status | awk '/^[[:space:]]+[0-9]/{print '

Userparameter=nginx.requests,curl-s Http://172.16.1.99/status | awk '/^[[:space:]]+[0-9]/{print $} '


Save exit, restart Service

[Email protected] zabbix_agentd.d]# systemctl restart Zabbix-agent.service


On the server side view, can not ENO view state, directly with the second method can get the value, all succeeded


[Email protected] ~]# zabbix_get-s 172.16.1.99-k net.if.in[eno16777736,bytes]

285905110

[Email protected] ~]# zabbix_get-s 172.16.1.99-k nginx.active

1

[Email protected] ~]# zabbix_get-s 172.16.1.99-k nginx.accepts

9

[Email protected] ~]# zabbix_get-s 172.16.1.99-k nginx.handled

10

[Email protected] ~]# zabbix_get-s 172.16.1.99-k nginx.requests

11



Next you can create a new item item based on the above custom parameter userparameters, and you can enter the key you just customized.


After the hosts 172.16.1.99 host, click Items, and then create item

Create 4 monitoring items as follows, which is the one you just set, and note that the change in preprocessing is changed to per second


You can create a graph for these monitoring


After a while, view this graph with a value indicating that the custom parameter monitoring setting was successful.


The 6.nginx Scheduler creates a monitoring template, defined in the template: Items, trigger, graph.


Create an Nginx template

Create an item on this template, monitor inbound traffic, and note that preprocessing is changed to change per second


Create Trigger


To define action actions for triggers to be triggered


You need to define the media below the users in administration


Re-define media type in the email in media types


Create graph


7. Backend Apache service configuration monitoring template, defined in the template: Items, trigger, graph.


Create a Web Template


Create an item on this template, monitor outbound traffic, and note that the change in preprocessing is changed to per second


Create trigger in order to distinguish it from the above trigger, here severity is changed to high


Create graph



8. Link App templates

For example, next to host 172.16.1.99, select Templates

Link Nginx Template


The same steps are two back-end RS link templates


9. View the hosts, the custom configuration monitoring has just been successful.


Zabbix (vi): Project Combat--automatic discovery Nginx Scheduler and backend Web service cluster, custom parameter monitoring

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.