Skip to content

Commit 592a1f4

Browse files
committed
More robust output handling
1 parent d63fe6b commit 592a1f4

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

check_monit.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ def print_output(status, count_ok, count_all, items):
7070

7171
if len(items):
7272
for item in items:
73-
s = "OK" if item['status'] == 0 else "CRITICAL"
74-
print(' \\_ [{0}]: {1}'.format(s, item['name']))
75-
print(' ' + item['output'])
76-
73+
s = "OK" if item.get('status') == 0 else "CRITICAL"
74+
print(' \\_ [{0}]: {1}'.format(s, item.get('name', 'No Name')))
75+
print(' ' + item.get('output', 'None'))
7776

7877
def get_service_output(service_type, element):
7978
# Service Type Filesystem

0 commit comments

Comments
 (0)