From 4c1b081c284691d856be876a1c5b0347fa041c86 Mon Sep 17 00:00:00 2001 From: Sven Velt Date: Sat, 26 Dec 2020 23:15:53 +0100 Subject: [PATCH] Add plugin --- check_jitsi.py | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 check_jitsi.py diff --git a/check_jitsi.py b/check_jitsi.py new file mode 100755 index 0000000..2f1ba95 --- /dev/null +++ b/check_jitsi.py @@ -0,0 +1,94 @@ +#!/usr/bin/python3 + +from urllib.request import urlopen +import json +import sys + +data = json.loads(urlopen('http://127.0.0.1:8080/colibri/stats').read().decode('utf-8')) + +v = {} +c = { + 'conferences': { + 'selector': 'conferences', + 'warn': 3, + 'crit': 5, + }, + 'participants': { + 'selector': 'participants', + 'warn': 10, + 'crit': 15, + }, + 'largest_conference': { + 'selector': 'largest_conference', + 'warn': 10, + 'crit': 15, + }, + 'inactive_conferences': { + 'selector': 'inactive_conferences', + 'warn': 2, + 'crit': 3, + }, + + 'bit_rate_download': { + 'selector': 'bit_rate_download', + }, + 'bit_rate_upload': { + 'selector': 'bit_rate_upload', + }, + 'endpoints_sending_video': { + 'selector': 'endpoints_sending_video', + }, + 'endpoints_sending_audio': { + 'selector': 'endpoints_sending_audio', + }, + 'receive_only_endpoints': { + 'selector': 'receive_only_endpoints', + }, + 'p2p_conferences': { + 'selector': 'p2p_conferences', + }, + 'jitter_aggregate': { + 'selector': 'jitter_aggregate', + }, + + } + +retcode = [0, ] +out = [] +outout = [] +perfdata = [] + +retstring = {0:'OK', 1:'WARNING', 2:'CRITICAL'} + + + +for key in c.keys(): + v[key] = data.get(c[key]['selector']) + + crit = (c[key]).get('crit') + warn = (c[key]).get('warn') + if crit and v[key] >= c[key]['crit']: + state = 2 + elif warn and v[key] >= c[key]['warn']: + state = 1 + else: + state = 0 + + retcode.append(state) + if crit and warn: + out.append('%s %s' % (v[key], key)) + else: + outout.append('%s: %s' % (key, v[key])) + + perfdata.append('%s=%s;%s;%s;;' % (key, v[key], warn or '', crit or '')) + + +retcode = max(retcode) + +out = 'Jitsi %s' % (retstring.get(retcode) or 'UNKNOWN') + ': ' + ', '.join(out) + + +print(out + '|' + ' '.join(perfdata)) +print('\n'.join(outout)) +sys.exit(retcode) +