Monitor MySQL with Percona monitoring for Zabbix

Source: Internet
Author: User
Tags install php percona

System Requirements

Monitored host and MySQL monitoring account, Zabbix Agent 2.0 or more (preferably the same as the Zabbix-server version), PHP, Php-mysql (PHP version is not limited, tested 5.3 is possible. The best version is not too low), Percona monitoring Plugins for Zabbix

Installing the Zabbix Agent

Https://www.cnblogs.com/fishparadise/p/9067471.html

Installing Percona Plugin

Percona plugin requires PHP support to install the dependency package first:

yum install php php-mysqlwget https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.7/binary/redhat/7/x86_64/percona-zabbix-templates-1.1.7-2.noarch.rpm

Or go to Percona website to download RPM package

https://www.percona.com/downloads/percona-monitoring-plugins/LATEST/rpm -ivh percona-zabbix-templates-1.1.7-2.noarch.rpm

Add a dedicated account for the monitored MySQL

mysql>CREATE USER ‘zabbix_monitor‘@‘127.0.0.1‘ IDENTIFIED BY ‘zabbix456‘;mysql>GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT ON *.* TO ‘zabbix_monitor‘@‘127.0.0.1‘;
Configuring Percona Plugin

Change to MySQL account Zabbix_monitor

vim /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php$mysql_user = ‘zabbix_monitor‘;$mysql_pass = ‘zabbix456‘;$mysql_port = 3306;
vim /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.shHOST=127.0.0.1

If you want to modify the time interval at which Percona plugin collects data, modify the 300 in the code below to be the appropriate number, in seconds.

elif [ -e $CACHEFILE ]; then    # Check and run the script    TIMEFLM=`stat -c %Y /tmp/$HOST-mysql_cacti_stats.txt`    TIMENOW=`date +%s`    if [ `expr $TIMENOW - $TIMEFLM` -gt 300 ]; then        rm -f $CACHEFILE        $CMD 2>&1 > /dev/null    fielse

Place the execution file Percona to execute in the Include directory of Zabbix (Zabbix call this file). Zabbix Agent with RPM installation default is:/etc/zabbix/zabbix_agentd.d/directory, specifically see Zabbix agent configuration file.

cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/
Test on client Side
/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg

If a number is returned, the success of the execution is proven.

Note: by vim get_mysql_stats_wrapper.sh default in the CACHEFILE="/tmp/$HOST-mysql_cacti_stats.txt" /tmp/ next generation of a temporary file, this file after the test to be manually deleted! Otherwise, the program will not be able to delete the file, resulting in Zabbix unable to collect data!

If the generated file is not data with the root user login manually, use the following command to test again:

/usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host 127.0.0.1 --items gg

The following error may be returned:

PHP MySQLi extension is not loaded

Installing the Php-mysql can

yum install php-mysql
Test on server side

(If the source is installed)

/usr/local/zabbix/bin/zabbix_get -s 192.168.1.51 -k system.cpu.util[,idle]

If a number is returned, the success of the execution is proven.

Configuring Zabbix-server Front-end pages

Installing Percona plugin with RPM will /var/lib/zabbix/percona/templates generate a template, but percona-zabbix-templates-1.1.7-2.noarch.rpm the generated template is the zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml version for Zabbix 2.0, which is already very old and not available.

Find a template for Zabbix 3.0 on the Web, log in
zabbix web:Configuration -> Templates -> 右上角的Import,把Screens, Maps, Images都选中,导入

The itmes update data interval for imported templates can also be modified.

Monitor MySQL with Percona monitoring for Zabbix

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.