]>
git.immae.eu Git - perso/Immae/Config/Nix.git/blob - flakes/private/monitoring/plugins/check_mysql_replication
1ee5de1470c71da3c2eaa3fc4054a5b776f05e07
10 info
=$(mysql --defaults-file=${config_file} -S $socket -e "show slave status" --vertical)
13 lag
=$(echo "$info" | grep "\bSeconds_Behind_Master\b" | cut -d':' -f2 | sed -e "s/\s//g")
15 IO_running
=$(echo "$info" | grep "\bSlave_IO_Running\b" | cut -d':' -f2 | sed -e "s/\s//g")
16 SQL_running
=$(echo "$info" | grep "\bSlave_SQL_Running\b" | cut -d':' -f2 | sed -e "s/\s//g")
18 if [[ $exit_code -ne 0 ]]; then
19 echo "UNKNOWN - Impossible to run mysql command"
21 elif [[ -z "$lag" ]]; then
22 echo "UNKNOWN - No replication found for mysql"
24 elif [[ "$IO_running" != "Yes" || "$SQL_running" != "Yes" ]]; then
25 echo "UNKNOWN - Replication is not running"
28 output
="Replication lag for mysql is ${lag}s"
29 LC_ALL
=C lag
=$(printf "%.*f" 0 $lag)
31 if [[ $lag -lt 5 ]]; then
32 echo "OK - $output | time=${lag}s;5;10;;"
34 elif [[ $lag -lt 10 ]]; then
35 echo "WARNING - $output | time=${lag}s;5;10;;"
38 echo "CRITICAL - $output | time=${lag}s;5;10;;"