Skip to content
This repository was archived by the owner on Jan 15, 2021. It is now read-only.

Commit 3d7f928

Browse files
committed
Prevent negative lag in pmp-check-mysql-replication-delay
1 parent ca16cdc commit 3d7f928

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

nagios/bin/pmp-check-mysql-replication-delay

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ main() {
4444
-u) shift; OPT_UTC=1; ;;
4545
-w) shift; OPT_WARN="${1}"; shift; ;;
4646
--master-conn) shift; OPT_MASTERCONN="${1}"; shift; ;;
47-
--channel) shift; OPT_CHANNEL="${1}"; shift; ;;
47+
--channel) shift; OPT_CHANNEL="${1}"; shift; ;;
4848
--unconfigured) shift; OPT_REPLNOTSET=1; ;;
4949
--ensure-sbm) shift; OPT_ENSURE_SBM=1; ;;
5050
--version) grep -A2 '^=head1 VERSION' "$0" | tail -n1; exit 0 ;;
@@ -91,6 +91,9 @@ main() {
9191
# Check for SQL thread errors
9292
LAST_SLAVE_ERRNO=$(awk '/Last_SQL_Errno/{print $2}' "${TEMP_SLAVEDATA}")
9393

94+
# Prevent Negative value due to NTP
95+
# Keep the highest value between 0 and level
96+
LEVEL=$([ "${LEVEL:-0}" -le "0" ] && echo 0 || echo $LEVEL)
9497
# Build the common perf data output for graph trending
9598
PERFDATA="replication_delay=${LEVEL:-0};${OPT_WARN};${OPT_CRIT};0;"
9699

@@ -150,7 +153,7 @@ get_slave_status() {
150153
# MariaDB multi-source replication
151154
mysql_exec "SHOW SLAVE '${OPT_MASTERCONN}' STATUS\G" > "${TEMP_SLAVEDATA}"
152155
elif [ "${OPT_CHANNEL}" ]; then
153-
mysql_exec "SHOW SLAVE STATUS FOR CHANNEL '${OPT_CHANNEL}'\G" > "${TEMP_SLAVEDATA}"
156+
mysql_exec "SHOW SLAVE STATUS FOR CHANNEL '${OPT_CHANNEL}'\G" > "${TEMP_SLAVEDATA}"
154157
else
155158
# Leverage lock-free SHOW SLAVE STATUS if available
156159
mysql_exec "SHOW SLAVE STATUS NONBLOCKING\G" > "${TEMP_SLAVEDATA}" 2>/dev/null ||

0 commit comments

Comments
 (0)