From 3d7f2eca05ebe5fdcf17f9e77e47cc62d326874b Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sat, 25 Nov 2023 14:27:13 +0100 Subject: [PATCH] Initial Nagios helper library --- __init__.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..3ffac6f --- /dev/null +++ b/__init__.py @@ -0,0 +1,22 @@ +#!/bin/python3 +# +import sys + + +class Nagios(object): + OK = 0 + WARNING = 1 + ERROR = 2 + UNKNOWN = 3 + STATUS_DICT = { + OK: 'OK', + WARNING: 'WARNING', + ERROR: 'ERROR', + UNKNOWN: 'UNKNOWN' + } + + def exit(self, status=UNKNOWN, msg="No Monitoring implemented."): + if status not in self.STATUS_DICT: + status = self.UNKNOWN + print(f"{self.STATUS_DICT[status]} - {msg}") + sys.exit(status)