From 7941b3e6aca92aabc6b7ced87d5747e8396f5060 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Sun, 3 Mar 2024 22:52:53 -0700 Subject: [PATCH] check_mysql_slave: fix null attributes --- check_mysql_slave.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/check_mysql_slave.py b/check_mysql_slave.py index 5b9029c..31d34f0 100755 --- a/check_mysql_slave.py +++ b/check_mysql_slave.py @@ -52,9 +52,7 @@ def main(args): sys.exit(nagios.STATE_UNKNOWN) last_io_error = slave_status['Last_IO_Error'] - if not last_io_error: - print("UNKNOWN - Could not retrieve Last_IO_Error") - sys.exit(nagios.STATE_UNKNOWN) + last_sql_error = slave_status['Last_SQL_Error'] replication_delay = -1 perfdata = {} @@ -72,16 +70,7 @@ def main(args): exit_msg.append(f'Last IO Error: {last_io_error.strip(".")}.') if exit_code == nagios.STATE_OK: - # Only check these things if everything else is healthy. - - last_sql_error = slave_status['Last_SQL_Error'] - if not last_sql_error: - print("UNKNOWN - Could not retrieve Last_SQL_Error") - sys.exit(nagios.STATE_UNKNOWN) - if last_sql_error: - exit_code = nagios.STATE_CRIT - exit_msg.append(f'Last SQL Error: {last_sql_error.strip(".")}.') - + # Only replication delay if everything else is healthy. if not slave_status['Seconds_Behind_Master']: print("UNKNOWN - Could not retrieve Seconds_Behind_Master") sys.exit(nagios.STATE_UNKNOWN)