How to Add MySQL Monitoring on Zabbix 3.2

zabbix mysql monitoringIn this article, I will show how to add MySQL database monitoring on Zabbix. I have two Ubuntu Server 16.04 virtual machines. The first one has installed Zabbix Server 3.2 and the second VM has MySQL 5.7 database that should be monitored.

Prerequirements

First of all, we need an installed Zabbix Agent on the VM with MySQL

Download Zabbix 3.2

$ wget http://repo.zabbix.com/zabbix/3.2/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.2-1+xenial_all.deb

Installing Zabbix Agent

$ sudo dpkg -i zabbix-release_3.2-1+xenial_all.deb
$ sudo apt update
$ sudo dpkg -s zabbix-agent
$ sudo apt install zabbix-agent

Configuring Zabbix Agent

sudo vim /etc/zabbix/zabbix_agentd.conf 

Find in file Server and ServerActive parameters and set there your Zabbix server IP or domain name.

Server=IPorHOSTNAME
ServerActive=IPorHOSTNAME

Restart Zabbix Agent

sudo systemctl restart zabbix-agent.service

And add it to autostart

sudo systemctl enable zabbix-agent.service

Now we have to add a new user to our MySQL database

$ mysql -u root -p
mysql> GRANT USAGE ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'pass';
mysql> FLUSH PRIVILEGES;

Check if line exists in Zabbix Agent configuration file /etc/zabbix/zabbix_agentd.conf

Include=/etc/zabbix/zabbix_agentd.d/*.conf

Check if file /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf exists

$ ls -lah /etc/zabbix/zabbix_agentd.d/

Create directory that is in HOME variable

$ sudo mkdir /var/lib/zabbix

And create file /var/lib/zabbix/.my.cnf with configuration

[client]
user = zabbix
password = pass

Restarting Zabbix Agent

$ sudo service zabbix-agent restart

Configuring Zabbix Server

Now go to your Zabbix Server web interface. Click on 'Configuration', 'Hosts' and 'Create host'.

zabbix create host

Enter 'Host name' of your MySQL server. You can check it in console

$ hostname

Select the needed group and enter MySQL server IP address in 'Agent interfaces'. Click 'Add' on the bottom of the page

zabbix host configuration

Now go to 'Hosts' and click on host 'Name'

zabbix hosts

Click on 'Templates' menu

zabbix mysql template

Start typing 'mysql' in 'Link new templates' and select the 'Template App MySQL'. Press 'Add' and 'Update'

That's all. Now we can see MySQL bandwidth and MySQL operations in 'Monitoring' -> 'Graphs'.

zabbix mysql operations graph

zabbix mysql bandwidth graph

Zabbix Client is configured now and you can check operations and bandwidth graphs through Zabbix Server web interface. You can also use this configuration to check MariaDB databases or add any other templates for monitoring the health of server or its services.

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.