Setting up the mysql_ Plugin in Munin

Fri Jul 12 2013 09:36:38 GMT-0400 (EDT)

After spending a few days trying to get the mysql_ plugin working in my munin installation, I've decided to write up the process. It include some pointers about troubleshooting and diagnosing problems with the plugin.

Once you have munin and mysql working:

# Save this to /etc/munin/plugin-conf.d/mysql_
[mysql_*]
  env.mysqlconnection DBI:mysql:mysql;host=127.0.0.1;port=3306
  env.mysqluser munin
  env.mysqlpassword 5uperS3cr3tPassw0rd

Next, create a new user in mysql:

mysql> CREATE USER munin@127.0.0.1 IDENTIFIED BY '5uperS3cr3tPassw0rd';
mysql> GRANT SUPER,PROCESS ON *.* TO munin@127.0.0.1;
mysql> GRANT SELECT ON mysql.* TO munin@127.0.0.1;
mysql> FLUSH PRIVILEGES;

You may need to install some perl dependencies:

yum install -y perl-Cache-Cache

Now, test that your new user is able to connect to the db thorough munin. You should not see any mysql errors printed here.

munin-node-configure --suggest 2>&1 | grep mysql

Next, install the suggested mysql plugins:

(munin-node-configure --shell 2>&1 | grep mysql | /bin/bash); service munin-node restart

Finally, you can confirm that the plugin is setup and working properly by testing it by running munin-run and telnet:

munin-run mysql_connections
  max_connections.value 151
  Max_used_connections.value 3
  Aborted_clients.value 2
  Aborted_connects.value 1
  Threads_connected.value 3
  Connections.value 36
telnet localhost 4949
  Trying 1.2.3.4...
  Connected to localhost.
  Escape character is '^]'.
  # munin node at localhost
  fetch mysql_connections
  max_connections.value 151
  Max_used_connections.value 3
  Aborted_clients.value 2
  Aborted_connects.value 1
  Threads_connected.value 3
  Connections.value 38
  .
  quit
  Connection closed by foreign host.

I was getting errors mentioning "# Bad exit" while using telnet; running munin-run showed the actual error messages.