Zabbix 3.0 monitoring MySQL [six]zabbix 3.0 monitoring MySQL [VI]
2016年10月9日18:25:29
zabbix
Author qq:381493251
Blog Address: www.abcdocker.com
Public Number: Abcdocker
Abcdocker AC Group: 454666672
If you encounter any problems can go to the group inquiry, we are a willing to help the collective!
MySQL monitoring
Zabbix has a template for monitoring MySQL, but it's not the Zabbix that really monitors MySQL. It percona
's a monitoring MySQL template for the company.
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
Using PHP to get mysql
the relevant information, so if we want to use percona
plug-in monitoring needs to be mysql
installed on the agent
side php
. 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 "Title=" "/>
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 http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm[[email protected] web]# yum install percona-zabbix-templates php php-mysql -y# The Percona plugin is going to get MySQL parameters via PHP, so we're going to install PHP and php-mysql We can view it 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脚本/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模板文件在percona组成我们已经说过了, here is just a little introduction.
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 import the template through the web
interface into the Zabbix
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/i6hykczdfwx54sl0ronn0j8g/2.png "alt=" 2.png-310.6kb "Title=" "/>
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/2smjc5pi86jhgs14sh3m0i87/2.png "alt=" 2.png-90kb " Title= ""/>
Tip: 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/#安装完软件包后会在/var/lib/zabbix/percona/templates/ Directory produces a configuration file, we copy it, because in the previous blog post, we have modified the Zabbix configuration file [include=/etc/abbix/zabbix_agentd.d/] so that the configuration file in this directory, Zabbix will find the relevant information in this directory himself [[email protected] web]# systemctl restart Zabbix-agent.service reboot!
You should configure a connection to MySQL below
When you /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.
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 certain value Key[[email Protected] ~]# Cat/var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf|grep gmUserParameter= Mysql.read-views,/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh 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 the value, stating no problem
tip: The path to the database in the shell script is localhost
, if we don't have authorization, we localhost
get the value.
[[email protected] scripts]# cat get_mysql _stats_wrapper.sh host=localhost res= ' home=~zabbix mysql -e ' SHOW slave status\g ' | egrep ' (slave_io_running| slave_sql_running): ' | awk -F: ' {print $2} ' | tr ' \ n ' ', ' # MySQL is obtained by command, if the environment variable is not the same may also affect the
Zabbix_web Interface Configuration
Template has been uploaded to Zabbix, this time we need to set the
650) this.width=650; "src="/HTTP// Static.zybuluo.com/abcdocker/ym7z1qqf1cgdhpio5cf71677/1.png "alt=" 1.png-155.4kb "title=" "/>
650) This.width =650, "src=" Http://static.zybuluo.com/abcdocker/zcnqi1p9rjw1bdz0mfqvqgau/2.png "alt=" 2.png-106.9kb "title="/>
prompt: We also need to authorize a file under/tmp, because by default Zabbix the value obtained in the file
650) this.width=650; "src="/HTTP/ Static.zybuluo.com/abcdocker/nts92qoge4turbbq6w8ecrzn/3.png "alt=" 3.png-60.7kb "title=" "/>
You can get the value after you modify it. So we also need to test
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/t0lns42e53pbmxyrzu3bczbc/4.png "alt=" 4.PNG-131.9KB "title=" "/>
Results such as
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/1278tv0fy21ahcj1m7q29las/5.png "alt=" 5.png-202.5kb "Title=" "/>
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 problems.
MySQL monitoring is complete!
650) this.width=650; "src=" Http://static.zybuluo.com/abcdocker/vt806lkpmeqneq9hf30lnxnf/weixin.gif "alt=" weixin.gif-425.6kb "title=" "/>
This article is from the "Abcdocker" blog, make sure to keep this source http://abcdocker.blog.51cto.com/11255059/1861663
Zabbix 3.0 monitoring MySQL [VI]