Zabbix detailed description of operation and maintenance monitoring Platform 2

Source: Internet
Author: User

1. Zabbix Architecture

Zabbix is an enterprise-class open source solution that provides distributed system monitoring and network monitoring capabilities based on a web interface. Zabbix can monitor various network parameters, ensure the safe operation of the server system, and provide a flexible notification mechanism to enable system administrators to quickly locate/resolve various problems.

The operating architecture of the Zabbix is as follows:



650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/86/04/wKiom1eypwfDDoBkAAPGeO8ndD4922.png "title=" 1.png " alt= "Wkiom1eypwfddobkaapgeo8ndd4922.png"/>


2. Components

The Zabbix consists of the following component parts:


1), Zabbix Server: Responsible for receiving the agent sent the report information of the core components, all configuration, statistics and operational data are organized by its organization;

2), Database Storage: Dedicated to storing all configuration information, as well as data collected by Zabbix;

3), Web Interface:zabbix GUI interface, usually run on the same host as server;

4), Proxy: Optional components, commonly used in distributed monitoring environment, the proxy server collects the monitoring data of the monitored side and sends it to the server side uniformly;

5, Agent: Deployed on the monitored host, responsible for collecting local data and to the server side or proxy side;


3. Process

By default Zabbix contains 5 programs: Zabbix_agentd, Zabbix_get, Zabbix_proxy, Zabbix_sender, Zabbix_server, and another zabbix_java_gateway is optional , this needs to be installed separately. Here are the respective roles of each of them.


Zabbix_agentd

The client daemon, which collects client data, such as CPU load, memory, hard disk usage, and so on.


Zabbix_get

The Zabbix tool, which is used separately, usually executes commands to obtain remote client information on the server or proxy side. Usually the user is wrongly discharged. For example, on the server side, we can use Zabbix_get to get the contents of the client to troubleshoot by getting the client's memory data.


Zabbix_sender

The Zabbix tool, used to send data to a server or proxy, is typically used for lengthy checks. Many checks are very time consuming, resulting in Zabbix timeouts. So we use sender to commit the data after the script has finished executing.

Zabbix_server

Zabbix Server daemon. Zabbix_agentd, Zabbix_get, Zabbix_sender, Zabbix_proxy, Zabbix_java_gateway data are ultimately submitted to the server

Note: Of course, is not the data are actively submitted to zabbix_server, there are some servers actively to fetch data.


Zabbix_proxy

Zabbix the agent daemon process. Functionally similar to server, the only difference is that it is just a broker that needs to submit/be submitted to the server for the collected data.


Zabbix_java_gateway

A feature introduced after the zabbix2.0. As the name implies: Java gateway, similar to AGENTD, but only for the Java aspect. It is important to note that it can only proactively fetch data, not passively. Its data will eventually be given to the server or proxy.


4. Zabbix related terminology in monitoring environment


Host: The network device to be monitored, which can be specified by IP or DNS name;

Host group: A logical container for hosts, which can contain hosts and templates, but hosts and templates within the same organization cannot be linked to each other; Host groups are typically used when assigning monitoring rights to users or groups of users;

Monitoring item: A specific monitoring indicator of the relevant data, the data from the monitored object; item is the core of Zabbix data collection, relative to a monitoring object, each item is identified by "key";

Trigger (Trigger): An expression that evaluates whether the data received within a particular item of a monitor object is within a reasonable range, that is, the threshold value, when the amount of data received is greater than the threshold, the trigger state is converted from "OK" to "problem", and when the data is restored to a reasonable range, it turns into "OK";

Event: Trigger a matter of concern, such as trigger state change, new agent or re-launch agent automatic registration, etc.;

Action: Refers to a pre-defined processing method for a particular event, such as sending a notification and when to perform the operation;

Alarm Media Type (media): means or channels for sending notifications, such as email, jabber, or SMS;

Template: A set of preset entries that are used to quickly define a monitored host, typically containing item, trigger, graph, screen, application, and low-level discovery rule ; templates can be linked directly to a host;

Front End (frontend): Zabbix Web Interface


5, Zabbix Installation

In the previous article we introduced the installation of Zabbix-server in the LNMP environment, so here is no longer explained, here is a brief description of the environment planning and zabbix-agent installation, operating system are centos6.7

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/86/04/wKiom1eyqTKz5qqMAAAkEqN0Txg122.png "title=" 1.png " alt= "Wkiom1eyqtkz5qqmaaakeqn0txg122.png"/>

Both servers are installed Zabbix-agent[[email protected] ~]# wget [[email protected] ~]# RPM-IVH zabbix-release-3.0-1.el6.noarch.rpm Prep Aring ########################################### [100%] 1:zabbix-release #################### ####################### [100%][[email protected] ~]# yum-y install zabbix-agent

[[email protected] ~]# vim/etc/zabbix/zabbix_agentd.conf Modify configuration file

server=172.16.80.117 #这个地址填写zabbix-server IP, default is 127.0.0.1

[[email protected] ~]#/etc/init.d/zabbix-agent start

Starting Zabbix agent: [OK]


6, monitoring the first host (172.16.80.128)

The Zabbix configuration process is basically as follows

Host groups (host group) →hosts (host) →applications (Monitoring item group) →items (Monitoring Item) →triggers (trigger) →event (event) →actions (processing action) →user Groups (user group) →users (user) →medias (alarm mode) →audit (log audit)


Configuration step is---->hosts---->create Host


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/86/04/wKiom1eyrJqQL91QAAE24Jvv0Eg609.png "title=" 1.png " alt= "Wkiom1eyrjqql91qaae24jvv0eg609.png"/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/86/04/wKioL1eyrdLTivB3AADj0VNhb2o327.png "title=" 1.png " alt= "Wkiol1eyrdltivb3aadj0vnhb2o327.png"/>


Next Select the Templates tab, enter the keyword Linux, we select the first module

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/86/04/wKioL1eyrj-yCTV9AABqnExQsRg325.png "title=" 1.png " alt= "Wkiol1eyrj-yctv9aabqnexqsrg325.png"/>


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/86/04/wKioL1eyrtjwE0sNAADrMNcrF_g567.png "title=" 1.png " alt= "Wkiol1eyrtjwe0snaadrmncrf_g567.png"/>

Then we can see the host we just added 172.16.80.128, what is the meaning of the red box we have already explained the relevant concept, here is no longer explained, in a moment can be out of the picture

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/86/04/wKioL1eyr66CquT0AADx0BgZcC0958.png "title=" 1.png " alt= "Wkiol1eyr66cqut0aadx0bgzcc0958.png"/>


7. User parameter users Parameters

Sometimes when we monitor a project that is not defined in the Zabbix predefined key, we can monitor the item item that we request by writing the Zabbix user parameter method. A little bit of an image. The user parameters in the Zabbix proxy configuration file is the equivalent of getting the value to be monitored by a script, and then writing the relevant script or command to the user parameter in the configuration file and Zabbix The return value in the server read configuration file is returned to the user by processing the front end.


7.1 Syntax for user parameters

Userparameter=<key>,<command>


Where userparameter is the keyword, key for user-defined key name can be casually up,<command> for the command or script we want to run.


A simple example:

Userparameter=ping,echo 1

The agent program will always return 1 when we add item on the server side of the key to ping.


A slightly more complex example

userparameter=mysql.ping,/usr/bin/mysqladmin-uroot-p123456 Ping | Grep-c Alive

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/86/04/wKioL1eysUizEMKoAAAjBnneA74624.png "title=" 1.png " alt= "Wkiol1eysuizemkoaaajbnnea74624.png"/>


When we perform the Mysqladmin-uroot ping command, if mysq survives to return mysqld is alive

, we use Grep–c to calculate the number of mysqld is alive, if the number of MySQL survival is 1, if not survive very obvious mysqld is alive number is 0, through this method we can determine the survival state of MySQL.

For Zabbix agent routines, if the MySQL surviving status sequence will return 1 if MySQL does not survive the state will return 0 when we add item on the server side of the key for mysql.ping.


7.2 Let key accept Parameters

By allowing key to also accept the parameters of the method to add more flexibility when the item, such as system predefined key:vm.memory.size[<mode>], where the mode pattern is the user to accept the parameters, When we fill in as free, we return the remaining size of the memory, and if we fill in the UserD, this returns the size of memory already used.


Related syntax

Configure the parameters in/etc/zabbix/zabbix_agentd.conf, as follows.


Userparameter=key,command


In addition to the above-mentioned notation, it also supports the formulation of parameter passing, as follows.


Userparameter=key[*],command $ ....


Describe

The value of the Key:key must be unique on the host system, where * represents the parameters accepted in the command

Commands: Commands that can be executed on the client system


Example 1:

Userparameter=ping[*],echo $

Ping[0]-would always return ' 0 '

PING[AAA]-would always return ' AAA '


Attention:


1. User-defined parameters must contain a key and a command, or it can be a script

The 2.key is unique throughout the system

3. User-defined parameter return value, maximum return 512 MB

4. After customizing, restart the service test key


7.3 Testing the connectivity of the website via user parameters 650) this.width=650; "Src=" http://s2.51cto.com/wyfs02/M01/86/05/ Wkiom1eys6gsnel7aaaygruzfwa509.png "title=" 1.png "alt=" Wkiom1eys6gsnel7aaaygruzfwa509.png "/>

You can see that the result of the command execution is that the return status code 200 indicates that the website is normal

[[email protected] ~]# vim /etc/zabbix/zabbix_agentd.conf   Modify the client configuration file unsafeuserparameters=1userparameter=http_check,/usr/bin/curl -o /dev/null -s -w  %{http_code} $1[[email protected] ~]# /etc/init.d/zabbix-agent restartshutting  down Zabbix agent:                                  [  OK  ]Starting Zabbix agent:                          &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;[&NBSP;&NBSP;OK&NBSP;&NBSP;] In the Zabbix-server test [[email protected] ~]# zabbix_get -s 172.16.80.128 -p 10050  -k  "http_check[172.16.80.128]"


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/86/06/wKiom1eyvQChhUK9AAAYOtGxcPQ607.png "title=" 1.png " alt= "Wkiom1eyvqchhuk9aaayotgxcpq607.png"/>


Add the appropriate item,triggers,graphs to the monitor side

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/86/05/wKioL1eyvpXia749AAC8s3nGyaI239.png "title=" 1.png " alt= "Wkiol1eyvpxia749aac8s3ngyai239.png"/>

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/86/06/wKiom1eyvvHybyPqAAB3Y07giMg966.png "title=" 1.png " alt= "Wkiom1eyvvhybypqaab3y07gimg966.png"/>


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/86/06/wKiom1eywAbD06wIAACg_sPF9nY529.png "title=" 1.png " alt= "Wkiom1eywabd06wiaacg_spf9ny529.png"/>


http_check[' 172.16.80.128 ']


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/86/06/wKioL1eywDPD6fnhAAB9eHb1kjA646.png "title=" 1.png " alt= "Wkiol1eywdpd6fnhaab9ehb1kja646.png"/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/86/06/wKioL1eywN2z-PGTAACbw9roQEo896.png "title=" 1.png " alt= "Wkiol1eywn2z-pgtaacbw9roqeo896.png"/>


Finally, let's take a look at the situation, and we'll simulate the situation where httpd is stopped.

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/86/08/wKiom1ey2nej_QcaAADGOOVapEA231.png "title=" 1.png " alt= "Wkiom1ey2nej_qcaaadgoovapea231.png"/>

8, through the Zabbix to monitor the status of Nginx nginx configuration # # #status server{Listen 80;      server_name status.martin.org;      Location/{stub_status on;        Access_log off; }   }


Access test

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/86/06/wKiom1eyxh2SXQyDAABJyiX988o042.png "title=" 1.png " alt= "Wkiom1eyxh2sxqydaabjyix988o042.png"/>


Activeconnections: The number of active connections initiated on the backend;

A total of 29,179 connections were processed by the server accepts 7:nginx;

Handled: Successfully created 29,179 handshake;

Requests: A total of 34952 requests were processed.

Reading:nginx read the number of headers of the client;

Writing:nginx the number of headers returned to the client;

Waiting:nginx request processing completed, waiting for the next request instruction connection.


Writing a script to detect Nginx

[[email protected] tools]# vim nginx.sh #!/bin/bashbkup_date= '/bin/date +%Y%m%d ' Log= "/var/log/nginx.log" host=status.martin.orgport= "# functions to return nginx " statsfunction active {  /usr/bin/curl  "/http $HOST: $PORT"  2>/dev/null|  grep   ' Active '  | awk  ' {print  $NF} '   }function reading {   /usr/bin/curl  "/http $HOST: $PORT"  2>/dev/null| grep  ' Reading '  |  awk  ' {print $2} '   }function writing {  /usr/bin/curl  ' http://$ HOST: $PORT " 2>/dev/null| grep  ' Writing '  | awk  ' {print $4} '   } function waiting {  /usr/bin/curl  "/http $HOST: $PORT"  2>/dev/null| grep   ' Waiting '  | awk  ' {print $6} '   }function accepts {  / usr/bin/curl  "http://$HOST: $PORT " 2>/dev/null| awk NR==3 | awk  ' {print $1} '   } function handled {  /usr/bin/curl  "/http $HOST: $PORT"  2>/dev/null| awk  NR==3 | awk  ' {print $2} '   }function requests {  /usr/ bin/curl  "/http $HOST: $PORT"  2>/dev/null| awk NR==3 | awk  ' {print  $   }# run the requested function$1} '
[[Email protected] alertscripts]# cp /tools/nginx.sh  /application/zabbix-server /share/zabbix/alertscripts/[[email protected] alertscripts]# chown zabbix.zabbix  nginx.sh [[email protected] alertscripts]# chmod +x /application/zabbix-server/ Share/zabbix/alertscripts/nginx.sh[[email protected] alertscripts]# vim /etc/zabbix/zabbix _agentd.conf userparameter=nginx.accepts,/application/zabbix-server/share/zabbix/alertscripts/nginx.sh  acceptsUserParameter=nginx.handled,/application/zabbix-server/share/zabbix/alertscripts/nginx.sh  handleduserparameter=nginx.requests,/application/zabbix-server/share/zabbix/alertscripts/nginx.sh  requestsuserparameter=nginx.connections.active,/application/zabbix-server/share/zabbix/alertscripts/nginx.sh  activeuserparameter=nginx.connections.reading,/application/zabbix-server/share/zabbix/alertscripts/ Nginx.sh readinguserparameter=nginx.connections.writing,/application/zabbix-server/share/zabbix/alertscripts/nginx.sh  writinguserparameter=nginx.connections.waiting,/application/zabbix-server/share/zabbix/alertscripts/nginx.sh  waiting[[email protected] alertscripts]# /etc/init.d/zabbix-agent restartshutting  down Zabbix agent:                                  [  OK  ]Starting Zabbix agent:                          &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;[&NBSP;&NBSP;OK&NBSP;&NBSP;]


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/86/07/wKioL1ey2ZvADcqrAABedhMUKzM367.png "title=" 1.png " alt= "Wkiol1ey2zvadcqraabedhmukzm367.png"/>



650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/86/07/wKioL1ey2yLj6zbpAAFCm6Q8rgQ016.png "title=" 1.png " alt= "Wkiol1ey2ylj6zbpaafcm6q8rgq016.png"/>


This article from "Thick tak" blog, declined reprint!

Zabbix detailed description of operation and maintenance monitoring Platform 2

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.