zabbix add mysql service monitoring (monitoring item comes with mysql and monitoring of the stencil percona mysql)

server1:

The first step: add mysql built-in monitoring module in the browser, and start the mysql service

Click Configuration -> Host -> zabbix server

Here Insert Picture DescriptionClick Templates -> Link indicator selection -> Groups (choose Templates / Databases) -> Template DB MYSQL

Here Insert Picture DescriptionHere Insert Picture DescriptionThis time to deploy the database:

[root@server1 zabbix]# cd zabbix_agentd.d/
[root@server1 zabbix_agentd.d]# ls
userparameter_mysql.conf
[root@server1 zabbix_agentd.d]# ll userparameter_mysql.conf 
-rw-r--r-- 1 root root 1531 Feb 25 17:42 userparameter_mysql.conf
[root@server1 zabbix_agentd.d]# cat userparameter_mysql.conf 

Here Insert Picture Description

[root@server1 zabbix_agentd.d]# ll -d /var/lib/zabbix
ls: cannot access /var/lib/zabbix: No such file or directory
[root@server1 zabbix_agentd.d]# mkdir /var/lib/zabbix
[root@server1 zabbix_agentd.d]# cd /var/lib/zabbix
[root@server1 zabbix]# ll /var/lib/mysql/mysql.sock 
srwxrwxrwx 1 mysql mysql 0 Aug  1 10:00 /var/lib/mysql/mysql.sock
[root@server1 zabbix]# vim .my.cnf

Here Insert Picture Description

[root@server1 zabbix]# vim .my.cnf
[mysql]
user = zabbix
password = westos
socket = /var/lib/mysql/mysql.sock

[mysqladmin]
user = zabbix
password = westos
socket = /var/lib/mysql/mysql.sock
[root@server1 zabbix]# systemctl restart zabbix-agent

Here Insert Picture DescriptionHere Insert Picture DescriptionRefresh this time, you will see the monitored items zabbix server was changed to 102, but there are also templates Template DB MYSQL

Here Insert Picture DescriptionStep Two: access to the database, the data is displayed in the page
Here Insert Picture DescriptionHere Insert Picture Descriptionview in the browser
Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description, but we feel that comes with mysql module monitors the term is too small, so we will increase the monitoring item by adding modules

The third step: increase mysql module

Import module to monitor mysql zabbix monitoring template percona (mysql open source analysis tool)

[root@foundation27 ~]# scp -r percona-zabbix-templates-1.1.8-1.noarch.rpm [email protected]:/mnt

Here Insert Picture Description

[root@server1 ~]# cd /mnt
[root@server1 mnt]# ls
4.0           nginx-1.15.8.tar.gz
nginx-1.15.8  percona-zabbix-templates-1.1.8-1.noarch.rpm
[root@server1 mnt]# rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm

Here Insert Picture Description

[root@server1 mnt]# cd /var/lib/zabbix/percona/templates
[root@server1 templates]# ls
userparameter_percona_mysql.conf
zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml
[root@server1 templates]# wc -l userparameter_percona_mysql.conf     
190 userparameter_percona_mysql.conf
[root@server1 templates]# cp userparameter_percona_mysql.conf  /etc/zabbix/zabbix_agentd.d/
[root@server1 templates]# cd /var/lib/zabbix/percona/scripts
[root@server1 scripts]# ls
get_mysql_stats_wrapper.sh  ss_get_mysql_stats.php
[root@server1 scripts]# vim ss_get_mysql_stats.php    #可以直接在这个里面修改mysql用户和密码 
[root@server1 scripts]# vim ss_get_mysql_stats.php.cnf   #也可以直接在这个里面修改mysql用户和密码,我就是在这个里面写入的
 [root@server1 scripts]# systemctl restart zabbix-agent.service

Here Insert Picture DescriptionWrite user and password
Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description

[root@server1 scripts]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg  #测试脚本是否可以正确执行,看是否可以取出值
[root@server1 scripts]# cd /tmp/
[root@server1 tmp]# ls
[root@server1 tmp]# rm -fr localhost-mysql_cacti_stats.txt    #删除

Here Insert Picture DescriptionHere Insert Picture DescriptionNote that this file is deleted because they want to serve their own generation

Step four: do the following in your browser

Click Configuration -> Templates -> select the link template
Here Insert Picture Descriptionto xml file import and Selection in the graphics (not selected polymerization graphics will not be displayed on the same screen, is not convenient)
Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description
click on the template, the Templates / Databases unlink, because you want to import new the mysql module, so be sure to old unlink

Select the group for Percona Templates in the Template Percona MySQL Server

After successfully added module, shows the following results, you click to update last

Here Insert Picture DescriptionPage updated as follows, this time to view the monitored item found to be 293, and the module also has a newly added module
Here Insert Picture Descriptionthe following screen appears after clicking Zabbix server, found that at this time there are many mysql module
Here Insert Picture Description

Published 250 original articles · won praise 2 · views 10000 +

Guess you like

Origin blog.csdn.net/yrx420909/article/details/104939526