Zabbix implementation of MySQL database monitoring (iv)

Source: Internet
Author: User

The previous content is to use the third-party developed plug-in for MySQL monitoring, there may be some of our concern about the monitoring content is not in it, then a common method is to define our own script and integrate it into the Zabbix, so that the original monitoring based on the strong complement. The following uses a script to monitor the master-slave replication status and alarm notification.

Let's introduce some common terms in Zabbix:

  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 stencils within the same group cannot link to each other, and host groups are typically used when group users or user groups assign monitoring permissions. Monitoring item: A specific monitoring indicator of the relevant data, the data from the monitored object, item is the core of data collection Zabbix, without item, there is no data, 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 amount of data is returned to a reasonable range, Its status will be converted from "problem" back to "OK". Event: A noteworthy event that occurs, such as the state transition of a trigger, the automatic registration of a new agent or a re-launch agent, and so on. Action: Refers to a pre-defined processing method for a specific event, by including an action (such as sending a notification) and a condition (when an action is taken). Alarm escalation (escalation): A custom scheme that sends an alert or executes a remote command, such as how often to send an alert every time. Media: means or channels for sending notifications, such as Email,jabber or SMS. Notification (motification): Information about an event that is sent to the user through the selected media. Remote command: A predefined command that can be executed automatically when the monitored host is under a certain condition. Template: Used to quickly define a set of preset entries for a monitored host, usually containing the item,trigger,graph,screen,application,low -level Discovery rule, templates can be linked directly to a single host. Application (Application): one or more HTTP requests to detect the availability of a Web site. Front End (frontend): Zabbix Web interface. 

First, the script monitoring

1. Create a monitoring user

' MPM '@'127.0.0.1'*3b9f0373bc48dcd0459d19550d373febcce003c8  '
Flush privileges;

2, write the monitoring script

#!/bin/SH#Created by: Healthy Grass #create Date: -/8/ -#Function: check mysql master-slave replication is OK or not ok.declare-a slave_is slave_is= ($ (/usr/local/mysql/bin/mysql-h127.0.0.1-umpm-p'MPM'-E"Show slave status \g"|grepRunning |awk '{print $}'))  if["${slave_is[0]}"="Yes"-A"${slave_is[1]}"="Yes" ]                Then                      Echo '2'#代表正常两个yes        Else                      Echo '-1'#代表不正常  fi

Execute the above script if the master-slave copy is normal, return status 0, otherwise return status 2.

3. Declare key in AGENTD configuration file

vim/usr/local/zabbix/etc/zabbix_agentd.conf# Add the following sentence Userparameter=mysql.replication,/data/scripts/check _replication. sh   #逗号前面是key, followed by the executed script

4. Restart the AGENTD service and test

[[email protected] etc]#/etc/init.d/zabbix_agentd Restart stop Zabbix agent:                                        [OK] starting Zabbix agent:                                     [OK] 

Then go to Zabbix server to see if you can get the monitoring value to key:

192.168. 245.131 " mysql.replication " warning:using a password on the command line interface can is insecure. 2

Okay, here the script is written, the following is the Zabbix Web page to create monitoring items, triggers, events and so on, the above mentioned several terms in series, to achieve the monitoring we need.

5, Zabbix Web side Add monitoring content

1) Create a monitoring item (item)

Click on the Create monitoring entry on the right to go to the following page:

type : Select Active mode here, need to open refreshactivechecks in agentd config file, indicate how often to request monitoring item detection, in seconds per server.
Key value: need to be the same as the key declared in the Agentd configuration file

2) Create a trigger

3) View monitoring effects

You can stop and start the master-slave copy separately to see the specific monitoring effect.

Stop slave:

Start slave:

Second, alarm notification

Zabbix implementation of MySQL database monitoring (iv)

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.