From 592a1f4bb767501b94e5d7a7a11894a69df19713 Mon Sep 17 00:00:00 2001 From: Markus Opolka <7090372+martialblog@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:17:55 +0100 Subject: [PATCH] More robust output handling --- check_monit.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/check_monit.py b/check_monit.py index e31c32a..ee8f8d5 100755 --- a/check_monit.py +++ b/check_monit.py @@ -70,10 +70,9 @@ def print_output(status, count_ok, count_all, items): if len(items): for item in items: - s = "OK" if item['status'] == 0 else "CRITICAL" - print(' \\_ [{0}]: {1}'.format(s, item['name'])) - print(' ' + item['output']) - + s = "OK" if item.get('status') == 0 else "CRITICAL" + print(' \\_ [{0}]: {1}'.format(s, item.get('name', 'No Name'))) + print(' ' + item.get('output', 'None')) def get_service_output(service_type, element): # Service Type Filesystem