update check_mysql_slave

This commit is contained in:
Cyberes 2024-04-05 23:51:42 -06:00
parent a2b6174b49
commit f911448a90
2 changed files with 12 additions and 14 deletions

View File

@ -1,13 +1,17 @@
# icinga2-checks # icinga2-checks
My custom Icinga2 checks. _My custom Icinga2 checks._
Useful: https://nagios-plugins.org/doc/guidelines.html#AEN200 Useful: https://nagios-plugins.org/doc/guidelines.html#AEN200
https://icinga.com/docs/icinga-2/latest/doc/05-service-monitoring/#performance-data-metrics https://icinga.com/docs/icinga-2/latest/doc/05-service-monitoring/#performance-data-metrics
`requirements-everybody.txt`: pip requirements for all Python 3 versions and Linux and BSD hosts. Should be easy to install on all hosts. `requirements-everybody.txt`: pip requirements for all Python 3 versions and Linux and BSD hosts. Should be easy to
install on all hosts.
`requirements-difficult.txt`: pip requirements that are easy to install on normal Debian hosts but complicated when there are wheels available. `requirements-difficult.txt`: pip requirements that are easy to install on normal Debian hosts but complicated when
there are wheels available.
These scripts have varying levels of code quality.
## Fix `dbus` Issues ## Fix `dbus` Issues

View File

@ -5,7 +5,8 @@ import traceback
import mysql.connector import mysql.connector
from checker import nagios, print_icinga2_check_status from checker import nagios
from checker.result import quit_check
from checker.types import try_int from checker.types import try_int
""" """
@ -107,19 +108,12 @@ def main(args):
}, },
} }
text_result = ' '.join(exit_msg) quit_check(' '.join(exit_msg), exit_code, perfdata)
print_icinga2_check_status(text_result, exit_code, perfdata)
sys.exit(exit_code)
except mysql.connector.Error as e: except mysql.connector.Error as e:
print("UNKNOWN - Could not connect to database!") quit_check(f'Could not connect to database: {e}', nagios.STATE_CRIT)
print(e)
sys.exit(nagios.STATE_UNKNOWN)
except Exception as e: except Exception as e:
print(f"UNKNOWN - {e}") quit_check(f'Unknown error: {e}\n{traceback.format_exc()}', nagios.STATE_UNKNOWN)
traceback.print_exc()
sys.exit(nagios.STATE_UNKNOWN)
finally: finally:
if cursor: if cursor:
cursor.close() cursor.close()