diff options
Diffstat (limited to 'modules/private/monitoring/plugins/check_mysql_replication')
-rwxr-xr-x | modules/private/monitoring/plugins/check_mysql_replication | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/private/monitoring/plugins/check_mysql_replication b/modules/private/monitoring/plugins/check_mysql_replication index 4027f63..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 | |||
10 | info=$(mysql --defaults-file=${config_file} -S $socket -e "show slave status" --vertical) | 10 | info=$(mysql --defaults-file=${config_file} -S $socket -e "show slave status" --vertical) |
11 | exit_code=$? | 11 | exit_code=$? |
12 | 12 | ||
13 | lag=$(echo "$info" | grep Seconds_Behind_Master | cut -d':' -f2 | sed -e "s/\s//g") | 13 | lag=$(echo "$info" | grep "\bSeconds_Behind_Master\b" | cut -d':' -f2 | sed -e "s/\s//g") |
14 | |||
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") | ||
14 | 17 | ||
15 | if [[ $exit_code -ne 0 ]]; then | 18 | if [[ $exit_code -ne 0 ]]; then |
16 | echo "UNKNOWN - Impossible to run mysql command" | 19 | echo "UNKNOWN - Impossible to run mysql command" |
@@ -18,6 +21,9 @@ if [[ $exit_code -ne 0 ]]; then | |||
18 | elif [[ -z "$lag" ]]; then | 21 | elif [[ -z "$lag" ]]; then |
19 | echo "UNKNOWN - No replication found for mysql" | 22 | echo "UNKNOWN - No replication found for mysql" |
20 | exit $STATE_UNKNOWN | 23 | exit $STATE_UNKNOWN |
24 | elif [[ "$IO_running" != "Yes" || "$SQL_running" != "Yes" ]]; then | ||
25 | echo "UNKNOWN - Replication is not running" | ||
26 | exit $STATE_UNKNOWN | ||
21 | else | 27 | else |
22 | output="Replication lag for mysql is ${lag}s" | 28 | output="Replication lag for mysql is ${lag}s" |
23 | LC_ALL=C lag=$(printf "%.*f" 0 $lag) | 29 | LC_ALL=C lag=$(printf "%.*f" 0 $lag) |