aboutsummaryrefslogtreecommitdiff
path: root/modules/private/monitoring/plugins/check_mysql_replication
diff options
context:
space:
mode:
Diffstat (limited to 'modules/private/monitoring/plugins/check_mysql_replication')
-rwxr-xr-xmodules/private/monitoring/plugins/check_mysql_replication8
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
10info=$(mysql --defaults-file=${config_file} -S $socket -e "show slave status" --vertical) 10info=$(mysql --defaults-file=${config_file} -S $socket -e "show slave status" --vertical)
11exit_code=$? 11exit_code=$?
12 12
13lag=$(echo "$info" | grep Seconds_Behind_Master | cut -d':' -f2 | sed -e "s/\s//g") 13lag=$(echo "$info" | grep "\bSeconds_Behind_Master\b" | cut -d':' -f2 | sed -e "s/\s//g")
14
15IO_running=$(echo "$info" | grep "\bSlave_IO_Running\b" | cut -d':' -f2 | sed -e "s/\s//g")
16SQL_running=$(echo "$info" | grep "\bSlave_SQL_Running\b" | cut -d':' -f2 | sed -e "s/\s//g")
14 17
15if [[ $exit_code -ne 0 ]]; then 18if [[ $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
18elif [[ -z "$lag" ]]; then 21elif [[ -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
24elif [[ "$IO_running" != "Yes" || "$SQL_running" != "Yes" ]]; then
25 echo "UNKNOWN - Replication is not running"
26 exit $STATE_UNKNOWN
21else 27else
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)