diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-11-25 00:41:12 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-11-25 00:41:12 (GMT) |
commit | 6014b438ade5bfe80681d4b4201c7252bcee04c6 (patch) | |
tree | 4ecbd1b247dc5852690fa99481a8aced1d949360 /checks/rhctl | |
parent | 7cbbe5220511fb3d28661cb7fccd3cf2d1fc50e3 (diff) |
added rhctl check
Diffstat (limited to 'checks/rhctl')
-rw-r--r-- | checks/rhctl | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/checks/rhctl b/checks/rhctl new file mode 100644 index 0000000..77afaa3 --- /dev/null +++ b/checks/rhctl @@ -0,0 +1,75 @@ +OK = 0 +WARN = 1 +CRIT = 2 +UNKNOWN = 3 + +def get_data(info): + import json + all = "" + for line in info: + all = all + ' '.join(line) + return json.loads(all) + +def inventory_rhctl_status(info): + try: + inventory = [] + inventory.append((None,None)) + return inventory + except Exception, e: + return [] + + +def check_rhctl_status(item, params, info): + try: + data = get_data(info) + if data['Mood'] == 'awakening': + return (WARN, 'rhctl is awakening') + if data['Mood'] == 'happy': + return (OK, 'rhctl is happy, active server is %s' % data['ActiveServer']) + if data['Mood'] == 'nervous': + return (WARN, 'rhctl is nervous(!), active server is %s' % data['ActiveServer']) + if data['Mood'] == 'sad': + return (CRIT, 'rhctl is sad(!!), last active server was %s' % data['ActiveServer']) + return (UNKNOWN, 'rhctl has unknown(!!) mood: %s' % data['Mood']) + except Exception, e: + return (UNKNOWN, "rhctl check failed: %s" % e.message) + + + +def inventory_rhctl_server(info): + try: + inventory = [] + data = get_data(info) + for server in data['Server']: + inventory.append((str(server),None)) + return inventory + except Exception, e: + return [] + + +def check_rhctl_server(item, params, info): + try: + data = get_data(info) + if item not in data['Server']: + return (UNKNOWN, 'server %s is missing(!!) in status report' % item) + if data['Server'][item]['Health'] == "alive": + return (OK, 'server %s is alive' % item) + if data['Server'][item]['Health'] == "dead": + return (CRIT, 'server %s is dead(!!)' % item) + return (UNKNOWN, 'server %s health is unknown(!!): %s' % (item, data['Server'][item]['Health'])) + except Exception, e: + return (UNKNOWN, "rhctl check failed: %s" % e.message) + + + +check_info["rhctl.mood"] = { + 'check_function': check_rhctl_status, + 'inventory_function': inventory_rhctl_status, + 'service_description': 'Mood of rhctl', +} + +check_info["rhctl.server"] = { + 'check_function': check_rhctl_server, + 'inventory_function': inventory_rhctl_server, + 'service_description': 'rhctl state of server %s', +} |