mariusv.com

Watch as I awkwardly stumble through life

Monitoring MySQL Replication with Munin and mk-heartbeat

Posted by Marius Voila on February 25, 2010 in London, U.K . — 0 comments This post contains 153 words

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:

#!/bin/bash

## Plug-in to Monitor MySQL Replication Delay.

#

#$Author: mariusv $

#$Date: 2010-02-25 13:29:21 $

#$RCSfile: mysql_rep_delay,v $

#$Revision: 1.1 $

case $1 in

        config)

                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

EOM

                exit 0;;

esac

echo -n "mysql_rep_delay.value "

mk-heartbeat -D test --check -h localhost