Nagios Scripts

The script can be used to have Nagios keep an eye on a suspected problem in MySQL Server (any version) where a master-slave connecion appears to be running fine, the slave is waiting for new log events, but the master is already ahead. This script catches the problem, and the workaround is to then do STOP SLAVE; START SLAVE;

Thanks to Mark Barger for updating the script for this purpose.

The script will alert based on the configurable difference in bin log position between a master and slave server. To call the script in a MySQL master/slave environment, with a DRBD backend use:

./ -m -s -p password -u username -k /drbd/mysql/data/mysql.sock

This will use -m as the master, -s as the slave, -p for password, -u for username, -k as your socket (sitting on DRBD backend) and use the default Nagios warning and critical levels of 1000 and 5000 respectively.

You may also be interested in ProActive Service - Open Query can take care of the maintenance and tuning of your MySQL servers, including setup of monitoring tools. From only 249/month.


check_mysql_perf is a plugin for Nagios which allows you to monitor various performance-related characteristics of a MySQL database.

The -m option tells the plugin the desired mode. Possible keywords are:

slave-lag (Check 'Seconds behind master')
slave-io-running (Check for 'Slave io running: Yes')
slave-sql-running (Check for 'Slave sql running: Yes')
threads-connected (Check 'Threads connected')
threadcache-hitrate (Check 'Thread cache hitrate')
querycache-hitrate (Check 'Query cache hitrate')
keycache-hitrate (Check 'MyISAM Key cache hitrate')
bufferpool-hitrate (Check 'InnoDB Buffer pool hitrate')
tablecache-hitrate (Check 'Table cache hitrate')
table-lock-contention (Check 'Table lock contention')
temp-disk-tables (Check 'Percent of temp tables created on disk')
connection-time (Check 'Seconds to get a connection')
slow-queries (Check 'Slow queries'*)
qcache-lowmem-prunes (Check 'Query cache entries pruned because of low
bufferpool-wait-free (Check 'InnoDB Buffer pool waits for clean page
log-waits (Check 'InnoDB log waits because of a too small
log buffer'*)

check_mysql_perf -m qcache-hitrate
OK - Query Cache Hitrate at 93.93%|qcache_hitrate=93.93%;90:;80:

check_mysql_perf -m qcache-hitrate -w 95: -c 90:
WARNING - Query Cache Hitrate at 93.93%|qcache_hitrate=93.93%;95:;90:

check_replication.pl3.86 KB