linux open-source tech

Monitoring MySQL Replication with Munin and mk-heartbeat

We use Munin and MySQL Replication from our production systems for hot standby purposes. But how to know if replication breaks?

Using components of the excellent MySQL Toolkit, I wrote a Munin plug-in to monitor replication delay and alert with an email if the delay gets above a certain level. This requires running mk-heartbeat as a daemon.
Here’s the plugin code:

## Plug-in to Monitor MySQL Replication Delay.
#$Author: imran $
#$Date: 2008-09-01 09:29:21 $
#$RCSfile: mysql_rep_delay,v $
#$Revision: 1.1 $
case $1 in
                cat <<'EOM'
graph_title MySQL Replication Delay
graph_vlabel seconds
mysql_rep_delay.label delay
mysql_rep_delay.warning 60
mysql_rep_delay.critical 3600
graph_category mysql
                exit 0;;
echo -n "mysql_rep_delay.value "
mk-heartbeat -D test --check -h localhost

In Munin, you will eventually get graphs of your replication delay like this:

open-source tech

High Performance MySQL: 2nd Edition

Back in August I attended the excellent YAPC::Europe 2008 in Copenhagen, Denmark.

While there I met the legendary (to me anyway) Larry Wall – father of Perl. Not only is he a humble and pleasant chap, he also cheerfully signed my “Learning Perl” book. Anyhow, O’Reilly had a stand there and were touting a healthy discount on all the books. I purchased this excellent book and have found it a treasure trove of advice.

Maybe this will get known as the “Falcon book” in years to come in the same way the classic Perl “Camel” and “Llama” book are known?