summaryrefslogtreecommitdiffstats
path: root/web/attachments/112910-check_mysql_slave
blob: 9b1e3c8063f7f1731838b766933546f06d40019c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh
#
# Check that a mysql-slave is running
#
# usage: check_mysql_slave host user password
#
# @author peter.romianowski@optivo.net
# @version 1.0 19.12.2004

IO=`mysql -h$1 -u$2 -p$3 -B -e "SHOW SLAVE STATUS" | cut -f 10 | tr "\n" " "`

if [ "$IO" != "Slave_IO_Running Yes " ] ; then
        echo "CRITICAL Slave IO-Thread is not running (response was: $IO)"
        exit 1
fi

SQL=`mysql -h$1 -u$2 -p$3 -B -e "SHOW SLAVE STATUS" | cut -f 11 | tr "\n" " "`

if [ "$SQL" != "Slave_SQL_Running Yes " ] ; then
        echo "CRITICAL Slave SQL-Thread is not running (response was: $SQL)"
        exit 2
fi

echo "OK Slave IO- and SQL-Thread are running"
exit 0