In this article, I am going to show how to use cacti monitoring for MySQL. For test purposes, I will use Ubuntu 16.04 with cacti 0.8.8f and MySQL 5.6 installed. If you don't have anything installed refer to our setup cacti on ubuntu article.
Download Percona Template
First of all, we have to download the needed percona MySQL template for cacti
$ wget https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.7/binary/debian/yakkety/x86_64/percona-cacti-templates_1.1.7-2.yakkety_all.deb
Install Template
We will use dpkg command to install Percona template.
$ sudo dpkg -i percona-cacti-templates_1.1.7-2.yakkety_all.deb
Grant Access for Cacti User
Now we need to create a cacti user in every MySQL database that we want to monitor.
mysql > GRANT SUPER, PROCESS ON *.* TO 'cacti'@'%' IDENTIFIED BY "qwe";
Importing MySQL template
Use below command to import
$ sudo php /usr/share/cacti/cli/import_template.php --filename=/usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mysql_server_ht_0.8.6i-sver1.1.7.xml --with-user-rras='1:2:3:4'
Check /usr/share/cacti/site/include/config.php
to ensure that the DB password is correct.
Edit file /usr/share/cacti/scripts/ss_get_mysql_stats.php
and change username and password.
$mysql_user = 'cacti'; $mysql_pass = 'qwe';
Now we can go to the web interface and add the needed graphs. Click on 'New graphs' and add the needed one.
Select the template for monitoring and click 'Create'
Click 'Graphs' on the top menu.
In this article, we have imported Percona MySQL template into cacti monitoring system and created a couple of graphs to monitor MySQL database. For any additional information, you can refer to percona official documentation.