How To Setup MySQL Enterprise Monitoring with Zabbix

This article is NOT about how to setup the application called MySQL Enterprise Monitor but rather how to setup MySQL monitoring in your Zabbix Enterprise Monitoring software.

Here’s how this works:

  • – Network communication to the server provided by the Zabbix Agent.
  • – Agent side UserParameter settings allow for needed commands to be run against MySQL
  • – Server side MySQL Host Templates are used to apply the checks, create graphs etc.

Agent Side Configuration (the box you’re monitoring):

We assume you have your Zabbix server and agent up and running properly.

On the Scientific Linux/CentOS repository packages provided by Zabbix, a default configuration file is included with everything you need.

[ ~]#  cd /etc/zabbix/zabbix_agentd.d/

[root@ zabbix_agentd.d]# ls

Taking a look at that file, which by the way is enabled by having this line in your agent config file (should be already enabled)


Right so taking a look at the userparameter_mysql.conf file, these are the lines which perform the actual MySQL checks:

UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -N | awk '{print $$2}'

UserParameter=mysql.size[*],echo “select sum($(case “$3″ in both|””) echo “data_length+index_length”;; data|index) echo “$3_length”;; free) echo “data_free”;; esac)) from information_schema.tables$([[ “$1” = “all” || ! “$1″ ]] || echo ” where table_schema=’$1′”)$([[ “$2” = “all” || ! “$2” ]] || echo “and table_name=’$2′”);” | HOME=/var/lib/zabbix mysql -N,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive

UserParameter=mysql.version,mysql -V

Alright so you don’t need to change anything in the above file at all, just notice that the HOME variable is set to “/var/lib/zabbix”.

NOTE: If you’re using RHEL 5 instead of 6, see my notes at the bottom about it.

Now, this next step should be the first change you’ve actually made thus far:

[ ~]# mkdir /var/lib/zabbix

Right, now you can place your MySQL client connection information into this directory.  When the Zabbix agent runs the UserParameter commands, it will check the /var/lib/zabbix/.my.cnf  for a username and password.  So that means you need something like the following in your /var/lib/zabbix/.my.cnf file:


 Grant Access In MySQL Server for the zabbix_boy user account (or whatever you call you account, probably something like “moniton_the_unstoppable”): 

So login as root and run these in MySQL:

mysql> create user 'zabbix_boy'@'localhost' IDENTIFIED BY 'boyimtired';
mysql> SET PASSWORD FOR 'zabbix_boy'@'localhost' = PASSWORD('boyimtired');
mysql> GRANT USAGE ON *.* TO 'zabbix_boy'@'localhost' IDENTIFIED BY 'boyimtired';
mysql> flush privileges;


Login to Zabbix and go to Configuration > Hosts > Add the App MySQL template to your host and BOOM.

You’ll start getting a status and uptime monitor plus metrics and graphs on the following info:

  • bytes received/sent per second
  • deletes per second
  • inserts per second
  • queries per second
  • selects per second
  • slow queries
  • status, uptime
  • update ops per second

Pretty fucking awesome!

CENTOS 5: I’ve had no issues with the above steps on CentOS/RHEL/Scientific Linux 6 but it seems to just read from your standard /etc/my.cnf for client connection info in CentOS 5.  So just throw the [Client] lines into your /etc/my.cnf and it should be fine.  If not, you’ll probably get access denied errors in your agent log because it will just try to connect to MySQL via localhost using “zabbix” username and no password.



John (February 4, 2015)

thank you! excellent step by step!

Parth Kachchhi (March 9, 2016)

I get the following error while navigating zabbix MySQL items:

Received value [ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (13)] is not suitable for value type [Numeric (float)]

Also the items are marked as ‘Not Supported’ except for the item ‘mysql.version’.

Orkhan (June 20, 2017)

A lot of thanks for guide.
It helped me to connect Template MySQL App and receive all items.
Zabbix 3.0.2 on CentOS 7

Comments are closed.