Using Percona to monitor a database
Need. PHP php-mysql and this package below
Download package
wget https://mirrors.tuna.tsinghua.edu.cn/percona/yum/el7/percona-zabbix-templates-1.1.7-2.noarch.rpm Yum Install -Y php Php-mysql
Installation
[Email protected] ~]# RPM-IVH percona-zabbix-templates-1.1.7-2.noarch.rpm Warning: Percona-zabbix-templates-1.1.7-2.noarch.rpm:header V4 dsa/sha1 Signature, key ID cd2efd2a:nokeypreparing ... ################################# [100%]updating/installing ... 1:percona-zabbix-templates-1.1.7-2 ################################# [100%]scripts is installed to/var/lib/zabbix/ Percona/scriptstemplates is installed To/var/lib/zabbix/percona/templates[[email protected] ~]#
modifying configuration information
#拷贝模板 [[email protected] scripts]# Cp/var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf/etc/zabbix /zabbix_agentd.d/
#通过下面的命令可以看出conf文件里面是执行了一个脚本 + Pass-through parameters [[email protected] scripts]# tail-4/etc/zabbix/zabbix_agentd.d/userparameter_ Percona_mysql.conf Userparameter=mysql.query-time-count-09,/var/lib/zabbix/percona/scripts/get_mysql_stats_ Wrapper.sh ouuserparameter=mysql.open-files,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh ijuserparameter=mysql.state-closing-tables,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh Lquserparameter=mysql.running-slave,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh Running-slave
#所以我们要去查看下这个脚本, whether you need to configure new information # Add MySQL account password warm tip: The path to the database in the shell script is localhost, and if we do not authorize localhost will not get the value
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8F/0D/wKiom1jSLc3DVCkLAAAy6JSSsfE351.png-wh_500x0-wm_ 3-wmp_4-s_409475129.png "title=" Mysql.png "alt=" Wkiom1jslc3dvcklaaay6jsssfe351.png-wh_50 "/>
Edit ss_get_mysql_stats.php to add MySQL related configuration
$mysql _user = "; $mysql _pass ="; $mysql _port = 3306; $mysql _socket = NULL; $mysql _flags = 0; $mysql _ssl = FALSE; # Whether to with SSL to connect to MySQL. $mysql _ssl_key = '/etc/pki/tls/certs/mysql/client-key.pem '; $mysql _ssl_cert = '/E Tc/pki/tls/certs/mysql/client-cert.pem '; $mysql _ssl_ca = '/etc/pki/tls/certs/mysql/ca-cert.pem '; $mysql _connection _timeout = 5;# Normal Here users we should create a dedicated monitor, as I am here to test the environment. It's not a waste of time.
Restart Agentd
Systemctl Restart Zabbix-agent.service
Test:
[Email protected] ~]# zabbix_get-s 192.168.56.21-k mysql.open-files51
Import of templates:
Download the Percona template and upload it to the Zabbix-server server.
[Email protected] ~]# sz Zabbix_mysql_servl.xml
When importing, the time of discovery expires. Import failed
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/8F/12/wKioL1jTLeTSsxUiAADB2uv0ODc179.png-wh_500x0-wm_ 3-wmp_4-s_148665190.png "title=" Date.png "alt=" Wkiol1jtletssxuiaadb2uv0odc179.png-wh_50 "/>
Here we use the editor, edit the above download of this XML file modification time modify the following fields
<date>2016-12-09 18:22:02</date> #我这里是把这个字段删了
Once again, there will be a lot of bugs that need to be modified step-by-step. this could be a Zabbix version 3.0 issue.
I use the modified template here to test
After the above import success, we create a new MySQL host, template using Percona, my template can see the item has 191
=============================
Here's a trigger dependency,
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/8F/12/wKioL1jTMaDCEHiBAABdwfF1pxM663.png-wh_500x0-wm_ 3-wmp_4-s_3901139190.png "title=" Yilai.png "alt=" Wkiol1jtmadcehibaabdwff1pxm663.png-wh_50 "/>
This article from the "Circle of a Bird" blog, declined to reprint!
Zabbix----4-----monitor MySQL