mysql monitoring
Zabbix comes with a template to monitor MySQL, but it's not Zabbix's own template that really monitors MySQL. But percona
A monitoring MySQL template
percona Official website: www.percona.com
Percona Composition Introduction
1, PHP script for data collection 2, Shell script to invoke the acquisition of Information 3, Zabbix configuration file 4, Zabbix template file
Installation Documentation: https://www.percona.com/doc/percona-monitoring-plugins/LATEST/zabbix/index.html
percona
PHP is used to getmysql
Information, so if we want to use thepercona
Plug-in monitoringmysql
You will need toagent
-End Installationphp
。 There is a write on the installation document OH ~
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/r6pp7vo0np74knqr71uf9iww/1.png "alt=" 1.png-135.5kb "Style=" Border:0px;font-family:inherit;font-style:inherit;margin:0px;padding:0px;vertical-align:middle;height: auto; "/>
installation steps: View the above link can also be installed
We installed it on the zabbix-server because there was a MySQL
[[Email protected] web]# yum install [[email protected] web]# yum install percona-zabbix-templates php php-mysql -y#percona plugin is to get MySQL parameters via PHP, So we're going to install PHP and php-mysql we can see it's all installed with those software [[email protected] web]# rpm -ql Percona-zabbix-templates /var/lib/zabbix/percona /var/lib/zabbix /percona/scripts var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh # Shell Scripts /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php #php获取mysql信息 /var/lib/zabbix/percona/templates /var /lib/zabbix/percona/templates/userparameter_percona_mysql.conf #zabbix配置文件 /var/ lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.6.xml # Zabbix template file in Percona We've already said, here's just a little bit of a description.
We will download the Zabbix template
[Email protected] web]# sz/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9- Sver1.1.6.xml
Then we need to pass the templateweb
Interface Import into Zabbix
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/i6hykczdfwx54sl0ronn0j8g/2.png "alt=" 2.png-310.6kb "Style=" Border:0px;font-family:inherit;font-style:inherit;margin:0px;padding:0px;vertical-align:middle;height: auto; "/>
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/2smjc5pi86jhgs14sh3m0i87/2.png "alt=" 2.png-90kb " Style= "Border:0px;font-family:inherit;font-style:inherit;margin:0px;padding:0px;vertical-align:middle;height: auto; "/>
Tips:If an error occurs, the issue may be Zabbix version 3.0. We provide a production template here
Download Link: http://pan.baidu.com/s/1pLjKvxh Password: 75g0
Then you can upload it from new
Copying a configuration file
[[email protected] web]# cp /var/lib/zabbix/percona/templates/userparameter_percona_ Mysql.conf /etc/zabbix/zabbix_agentd.d/[[email protected] web]# ls /etc/zabbix/zabbix _agentd.d/#安装完软件包后会在 The/var/lib/zabbix/percona/templates/directory to generate a profile, we copy it, because in the previous blog post, we have modified the Zabbix configuration file [include= /etc/abbix/zabbix_agentd.d/] so put the configuration file in this directory, Zabbix will be in this directory to find the relevant information [[email protected] web]# systemctl restart zabbix-agent.service reboot!
in /VAR/LIB/ZABBIX/PERCONA/SCRIPTS/SS_GET_MYSQL_STATS.PHP.CNF
Create a file
[[email protected] ~]# cat /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php.cnf< ?php$mysql_user = ' root '; $mysql _pass = '; #用户名密码可以自己创建, there is a password to write the password, no password is empty just fine
tip: Normal users Here we should create a dedicated monitor, as I am here to test the environment. It's not a waste of time.
Test
See if you can get a value and find a test
[[Email protected] ~]# cat /var/lib/zabbix/percona/templates/userparameter_percona_ mysql.conf Select a key[[email protected] ~]# cat /var/lib/that must have a value zabbix/percona/templates/userparameter_percona_mysql.conf|grep gmuserparameter=mysql.read-views,/var/lib/ ZABBIX/PERCONA/SCRIPTS/GET_MYSQL_STATS_WRAPPER.SH&NBSP;GM test results are as follows:[[email protected] ~]# cd /var/lib/zabbix/percona/scripts/[[email protected] scripts]# ./get_mysql_stats_wrapper.sh gm1[[email protected] scripts]# ./get_mysql_stats_wrapper.sh gw9736342 can get to value, stating no problem
> Tip: the path to the database in the shell script is localhost
, if we do not authorize localhost
will not get the value
[[email protected] scripts]# cat get_mysql_stats_wrapper.sh host=localhost res= ' Home=~zabbix mysql-e ' SHOW SLAVE S Tatus\g ' | Egrep ' (slave_io_running| slave_sql_running): ' | Awk-f: ' {print $} ' | Tr ' \ n ', ' #mysql是通过命令来获取的, if the environment variable is different it can also affect
Zabbix_web Interface Configuration
The template has been uploaded to Zabbix and we need to set it up
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/ym7z1qqf1cgdhpio5cf71677/1.png "alt=" 1.png-155.4kb "Style=" Border:0px;font-family:inherit;font-style:inherit;margin:0px;padding:0px;vertical-align:middle;height: auto; "/>
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/zcnqi1p9rjw1bdz0mfqvqgau/2.png "alt=" 2.png-106.9kb "Style=" Border:0px;font-family:inherit;font-style:inherit;margin:0px;padding:0px;vertical-align:middle;height: auto; "/>
Tips:We also need to authorize a file under/tmp, because by default Zabbix gets the value in the file
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/nts92qoge4turbbq6w8ecrzn/3.png "alt=" 3.png-60.7kb " Style= "Border:0px;font-family:inherit;font-style:inherit;margin:0px;padding:0px;vertical-align:middle;height: auto; "/>
You can get the value after you modify it, so we need to test
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/t0lns42e53pbmxyrzu3bczbc/4.png "alt=" 4.png-131.9kb "Style=" Border:0px;font-family:inherit;font-style:inherit;margin:0px;padding:0px;vertical-align:middle;height: auto; "/>
Results such as
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/1278tv0fy21ahcj1m7q29las/5.png "alt=" 5.png-202.5kb "Style=" Border:0px;font-family:inherit;font-style:inherit;margin:0px;padding:0px;vertical-align:middle;height: auto; "/>
thought:
If there is an error we need to look at the Shell's script first, because the shell is going to call PHP. There are many wrong factors, the simplest way is to use the shell behind the key to see if you can have a value.
Where the most error is the PHP and MySQL connection problems, as well as some of our MySQL licensing issues
This article is from the "Little Rookie" blog, please be sure to keep this source http://baishuchao.blog.51cto.com/12918589/1958378
Zabbix 3.0 monitoring MySQL