X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fprivate%2Fmonitoring%2Fplugins%2Fcheck_mysql_replication;h=1ee5de1470c71da3c2eaa3fc4054a5b776f05e07;hb=ef909e2435194af725f4338a13e4732328ef7361;hp=89239281b3da089fb6128a0fd4615de8baaa5c62;hpb=6015a3b52c3b155ac444aeb39950c38a5e653101;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/private/monitoring/plugins/check_mysql_replication b/modules/private/monitoring/plugins/check_mysql_replication index 8923928..1ee5de1 100755 --- a/modules/private/monitoring/plugins/check_mysql_replication +++ b/modules/private/monitoring/plugins/check_mysql_replication @@ -10,7 +10,10 @@ config_file=$2 info=$(mysql --defaults-file=${config_file} -S $socket -e "show slave status" --vertical) exit_code=$? -lag=$(echo "$info" | grep Seconds_Behind_Master | cut -d':' -f2 | sed -e "s/\s//g") +lag=$(echo "$info" | grep "\bSeconds_Behind_Master\b" | cut -d':' -f2 | sed -e "s/\s//g") + +IO_running=$(echo "$info" | grep "\bSlave_IO_Running\b" | cut -d':' -f2 | sed -e "s/\s//g") +SQL_running=$(echo "$info" | grep "\bSlave_SQL_Running\b" | cut -d':' -f2 | sed -e "s/\s//g") if [[ $exit_code -ne 0 ]]; then echo "UNKNOWN - Impossible to run mysql command" @@ -18,18 +21,21 @@ if [[ $exit_code -ne 0 ]]; then elif [[ -z "$lag" ]]; then echo "UNKNOWN - No replication found for mysql" exit $STATE_UNKNOWN +elif [[ "$IO_running" != "Yes" || "$SQL_running" != "Yes" ]]; then + echo "UNKNOWN - Replication is not running" + exit $STATE_UNKNOWN else output="Replication lag for mysql is ${lag}s" LC_ALL=C lag=$(printf "%.*f" 0 $lag) if [[ $lag -lt 5 ]]; then - echo "OK - $output" + echo "OK - $output | time=${lag}s;5;10;;" exit $STATE_OK elif [[ $lag -lt 10 ]]; then - echo "WARNING - $output" + echo "WARNING - $output | time=${lag}s;5;10;;" exit $STATE_WARNING else - echo "CRITICAL - $output" + echo "CRITICAL - $output | time=${lag}s;5;10;;" exit $STATE_CRITICAL fi fi