Skip to content

Commit

Permalink
improved check_zammad_health
Browse files Browse the repository at this point in the history
  • Loading branch information
zerwes committed Jan 16, 2024
1 parent e19375a commit ab4c8dc
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions files/check_zammad_health
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,28 @@ except FileNotFoundError:
ecode = 0
status = 'OK'
txt = ''
perfdata = '-'
perfdata = ''

if monitoring_token:
r = requests.get('%s?token=%s' % (monitoring_url, monitoring_token), timeout=5)
r = requests.get(f'{monitoring_url}?token={monitoring_token}', timeout=5)
if r.status_code == 200:
hstst = json.loads(r.text)
#print(hstst)
# {'healthy': True, 'message': 'success', 'issues': [], 'actions': []}
perfdata = 'issues=%s' % len(hstst['issues'])
perfdata = f'issues={len(hstst["issues"])}'
txt = hstst['message']
if not hstst['healthy']:
ecode = 1
status = 'WARNING'
else:
ecode = 2
status = 'CRITICAL'
txt = 'request failed: %s : %s' % (r.status_code, r.text,)
txt = f'request failed: {r.status_code} : {r.text}'
else:
ecode = 3
status = 'UNKNOWN'
txt = 'unable to get monitoring token'

if len(perfdata) > 0:
perfdata += '|'
perfdata += 'e=%s;1;2;0;3' % ecode
perfdata += f'e={ecode};1;2;0;3'

print('%s zammad_health_check %s %s - %s' % (ecode, perfdata, status, txt))
print(f'{ecode} zammad_health_check {perfdata} {status} - {txt}')

0 comments on commit ab4c8dc

Please sign in to comment.