Last active
August 29, 2015 13:58
-
-
Save bcicen/9984161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Nagios plugin to check for inserts updates deletes drops alters creates on slave DBs due to http://bugs.mysql.com/bug.php?id=58669 | |
function usage(){ | |
echo "Usage: $0 [mysql socket]" | |
} | |
if [ $# -eq 0 ]; then | |
echo -n "Missing mysql socket. " | |
usage | |
exit $STATE_UNKNOWN | |
fi | |
mysql_socket=$1 | |
binlog_dir=$(dirname $(grep -v '^#' /etc/mysql/my.cnf | grep 'log-bin' | cut -f2 -d\=)) | |
binlog=$(mysql --skip-column-names -S $mysql_socket -B -e 'show binary logs;' | tail -1 | awk '{print $1}') | |
results=$(strings ${binlog_dir}/${binlog} | egrep -i '(insert|update|delete|drop|alter|create)' | wc -l) | |
case $results in | |
[0]*) | |
echo "OK - No direct slave changes found" | |
exit 0 | |
;; | |
[1]*) | |
echo "WARNING - Direct slave modification found" | |
exit 1 | |
;; | |
[2]*) | |
echo "CRITICAL - Multiple direct slave modifications found" | |
exit 2 | |
;; | |
*) | |
echo "UNKNOWN - slave binlog check failed" | |
exit 3 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment