Skip to content

Monitoring MySQL with Munin on a DirectAdmin platform

Today I’ll be showing you how to monitor MySQL with Munin on a DirectAdmin platform. I’ve tested this setup for a customer on a CentOS box. It should be fairly easy to adapt this to Debian. You probably won’t even need to change credentials at all on a Debian box given the fact that it has an /etc/mysql/debian.cnf file by default. Although I’m not sure DirectAdmin puts it to good use. Any Debian/DirectAdmin users out there? Feel free to comment.

Let’s start off by checking the proper MySQL login credentials on our CentOS/RHEL box:

# cat /usr/local/directadmin/conf/mysql.conf

Easy enough. Let’s move on to installing munin and applying the credentials to the MySQL monitoring plugin. Munin isn’t available in the default repository. Not to worry, it’s in the Fedora Project’s EPEL repository for CentOS/RHEL. If you don’t have EPEL enabled yet be sure to check the excellent FAQ on the subject.

Or you could just move on to installing the repository.
For i386/i686:

# rpm -Uvh

For x86_64:

For x86_64: 
# rpm -Uvh

Now we can go on installing munin:

# yum install munin munin-node

Sadly this doesn’t install pull all the necessary dependencies. Not sure why the package maintainer missed out on this but it’s rather easy to fix it:

# yum install perl-Cache perl-Cache-Cache 
# yum install perl-IPC-ShareLite perl-DBD-MySQL

On to the credentials part. Edit the mysql plugin on line 132:

# vim +132 /usr/share/munin/plugins/mysql_

You should see something like this with the credentials left blank:

my %config = (
    'dsn'        => $ENV{'mysqlconnection'} || 'DBI:mysql:mysql',
    'user'       => $ENV{'mysqluser'}       || 'da_admin',
    'password'   => $ENV{'mysqlpassword'}   || 'removed',

As you can see I’ve already filled in the blanks.

Once the plugin has been configured we’re able to apply it. Before applying I’d suggest you take a look at what graphs are available:

# /usr/share/munin/plugins/mysql_ suggest

To apply all of them simply run the following:

# cd /etc/munin/plugins
# ln -sf /usr/share/munin/plugins/mysql_ mysql_
# for i in `./mysql_ suggest`; \
do ln -sf /usr/share/munin/plugins/mysql_ $i; done

If you only need a few of them you can apply them this way:

# cd /etc/munin/plugins
# ln -sf /usr/share/munin/plugins/mysql_ mysql_
# ln -sf /usr/share/munin/plugins/mysql_ mysql_bin_relay_log
# ln -sf /usr/share/munin/plugins/mysql_ mysql_commands
# ln -sf /usr/share/munin/plugins/mysql_ mysql_connections
# ln -sf /usr/share/munin/plugins/mysql_ $any_other_graph

Be sure to reload munin-node:

# /etc/init.d/munin-node restart

And that’s it. Enjoy your graphs at 🙂

Munin MySQL InnoDB graph

Published inHowto'sLinuxMonitoring


  1. Jan Van Buggenhout Jan Van Buggenhout

    Big WTF! Changing /usr/share/munin/plugins/mysql_ ??? You realize that this change will be gone once you upgrade the package?

    I don’t know the specifics on RedHat, but on debian you change /etc/munin/plugin-conf.d/munin-node :

    user someuser
    env.mysqlopts –defaults-extra-file=/etc/mysql/debian.cnf

    I’m pretty sure this is not something debian-specific and it will work on RH too…

  2. Tom Tom

    I’ve looked into it and you’d still need to edit /usr/share/munin/plugins/mysql_ to apply it.
    Which renders your “big wtf” pretty much useless.

  3. Its giving Segmentation Fault error.

  4. Tom Tom

    Which part is giving the segfault?

  5. I’m having consistently this error even installing perl-Cache and perl-Cache-Cache.
    # /usr/share/munin/plugins/mysql_ suggest
    Missing dependency Cache::Cache at /usr/share/munin/plugins/mysql_ line 703.

    I read the same message in several forums, but nobody has a good answer on that.

    Could you please give me a clue?
    Thanks in advance.

  6. dude dude

    I had to install the following on Centos 5.5
    yum install perl-IPC-ShareLite

    You could use the following instead of editing the mysql_ plugin:

    user root
    env.mysqluser da_admin
    env.mysqlpassword removed

    (For my charts the da_admin user needed SUPER privileges on the mysql server)

  7. Tom Tom

    @dude: Thanks for sharing! I’ll update my post asap.
    @Bruno: Have you tried to install the perl-IPC-ShareLite package?

  8. karthik v karthik v

    It is working.
    Nice thankyou

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.