summaryrefslogtreecommitdiff
path: root/checks/rhctl
diff options
context:
space:
mode:
Diffstat (limited to 'checks/rhctl')
-rw-r--r--checks/rhctl75
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',
+}