Monitor MySQL with Zabbix Auto discovery

Source: Internet
Author: User
Tags mysql login git clone

Introduced

Use Zabbix's low-level auto-discovery function to complete single-host multi-port monitoring, see low_level_discovery, the overall monitoring of percona-like Zabbix monitoring plug-ins, but with the mymonitor.pl replacement of the script ss_get_mysql_stats.php , and with A bit different.

Detailed code and configuration see: Zabbix_mysql

1. Structure Description:
zabbix_mysql/|-- readme.md|-- bin|   | --Get_mysql_stats_wrapper. SH              5 minutes Run Once |   | -- mymonitor.pl                            # equivalent to ss_get_mysql_stats.php script |   '-- mysql_port.pl                           # automatically discovers the MySQL port script, returns the JSON format output install. SH                                   # Installation script '-- templates    |-- userparameter_discovery_mysql.conf      # zabbix_ Agent configuration Parameters    '--zabbix_mysql_multiport.xml              # zabbix_server-side template

mymonitor.plThe script relies on the following modules:

Perl-DBIperl-dbd-mysql

The permissions required for monitoring include: PROCESS, SUPER, REPLICATION SLAVE in the mysql_port.pl script netstat to get the port running MySQL through the command, script to Zabbix user (or ordinary user) start, in order to avoid permissions problems, script install.sh default execution chmod +s /bin/netstat command.

mymonitor.pl script By default, the monitor/monitor user and password to connect to MySQL get state, you can modify the default password at the beginning of the script, or at run time to specify --user and --password related parameter information, you can /home/mysql/.my.cnf specify the user information, detailed can seeperldoc mymonitor.pl

get_mysql_stats_wrapper.shThe script defaults to reading the mymonitor.pl generated file in response to the Zabbix request, which is 5 minutes by default, and requires MySQL login information to be provided for slave detection because of the need for frequent (default 1 minutes) detection of the slave running state.

2. Installation Instructions

To operate on the agent side:

# git clone https://github.com/chenzhe07/zabbix_mysql.git/usr/local/zabbix_mysql# bash/usr/local /zabbix_mysql/Install. SH 192.168. 1.2

192.168.1.2For the intranet IP address, there may be more than one intranet IP, so there is no automatic acquisition, users need to manually add.

On server side operations:

Import templates/zabbix_mysql_multiport.xml using Zabbix UI ( import with Configuration, templates), and create< /c7>/edit hosts by assigning them "MySQL" group and linking the template "Mysql_zabbix" (Templates tab).

Import the template and add the template to the machine you want to monitor.

3. Testing
#Perlmymonitor.pl--host10.0.0.10--port3300--Items HVHV:36968# Perlmymonitor.pl--host10.0.0.10--port3300--Items Kxkx:1070879944# php ss_get_mysql_stats.php--host10.0.0.10--port3300--Items HVHV:36968# php ss_get_mysql_stats.php--host10.0.0.10--port3300--items KX KX:1070911408# Zabbix_get-S10.0.0.10-P10050-K"mysql.bytes-received[3300]"472339244134

Other features

Newer versions increase the INNODB transaction, lock, and long statement run detection:

Item                       throttlemax_duration             if then trigger an alarmwaiter_count              if Ten  Then trigger an alarmidle_blocker_duration     if  then trigger an alarm

Test as follows:

10050 " mysql.max_duration[3301] "  time4838781, User: [email protected]10.0. 21.5:59980

Monitor MySQL with Zabbix Auto discovery

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.