Skip to content

Instantly share code, notes, and snippets.

@michabbb
Created January 11, 2018 13:03
Show Gist options
  • Save michabbb/27a74d340e63398b4d3e8fef2ffdea28 to your computer and use it in GitHub Desktop.
Save michabbb/27a74d340e63398b4d3e8fef2ffdea28 to your computer and use it in GitHub Desktop.
Nagios Script for mysqldbcompare
#!/bin/bash
rm -f /tmp/dbcompareresult
OUTPUT=`docker run --rm --link your_mysql_container:mysql -v /tmp/:/tmp/ macropage/mysql-utilities bash -c 'mysqldbcompare --skip-row-count --skip-data-check --difftype=sql --compact --server1=user:pwd@mysql:3306 --server2=user:pwd@slave:3306 db1:db2 |tee /tmp/dbcompareresult; exit ${PIPESTATUS[0]}'`
if [ ! -f /tmp/dbcompareresult ]; then
echo "CRITICAL COMMAND DID NOT RUN!";
exit 2
fi
if [ $? -ne 0 ]; then
LASTLINE=`tail -1 /tmp/dbcompareresult`
echo "CRITICAL - $LASTLINE"
exit 2
else
echo "OK $LASTLINE - Slave Schema equal to Master"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment