summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-11-25 00:41:12 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-11-25 00:41:12 (GMT)
commit6014b438ade5bfe80681d4b4201c7252bcee04c6 (patch)
tree4ecbd1b247dc5852690fa99481a8aced1d949360
parent7cbbe5220511fb3d28661cb7fccd3cf2d1fc50e3 (diff)
added rhctl check
-rw-r--r--checks/gluster8
-rw-r--r--checks/mysql_repl2
-rw-r--r--checks/rhctl75
3 files changed, 80 insertions, 5 deletions
diff --git a/checks/gluster b/checks/gluster
index ef3e37f..64161c1 100644
--- a/checks/gluster
+++ b/checks/gluster
@@ -74,7 +74,7 @@ def inventory_gluster_volume_status(info):
uuids.append(line[0])
inventory.append((vol, uuids))
-
+
return inventory
@@ -93,7 +93,7 @@ def check_gluster_volume_status(item, params, info):
status = OK
message = "%i of %i bricks online" % (len(lines), len(params))
-
+
for uuid in uuids:
if uuids[uuid][0] > 0:
message += ", found new peer %s(!) - please update inventory" % uuid
@@ -107,7 +107,7 @@ def check_gluster_volume_status(item, params, info):
if uuids[uuid][2] != '1':
message += ", status(!) of peer %s" % uuid
status = WARN if WARN > status else status
-
+
p = (float(uuids[uuid][4]) / float(uuids[uuid][3])) * 100.0
if p < 20.0:
message += ", %s@%s has less then 20%% free space(!)" % (uuids[uuid][5], uuids[uuid][1])
@@ -124,7 +124,7 @@ def check_gluster_volume_status(item, params, info):
check_info["gluster.peers"] = {
'check_function': check_gluster_peers,
'inventory_function': inventory_gluster_peers,
- 'service_description': 'state of glusterfs peer',
+ 'service_description': 'state of glusterfs peer %s',
}
check_info["gluster.vol_status"] = {
diff --git a/checks/mysql_repl b/checks/mysql_repl
index 0b1cf74..ce4be4e 100644
--- a/checks/mysql_repl
+++ b/checks/mysql_repl
@@ -42,7 +42,7 @@ def check_mysql_repl_status(item, params, info):
return (CRIT, 'Slave %s is not(!!) running: %s' % (params[0], values['Last_%s_Error' % params[0]]), perfdata)
except Exception, e:
- return (UNKNOWN, "mysql_repl check failed: %", e.message)
+ return (UNKNOWN, "mysql_repl check failed: %s" % e.message)
check_info["mysql_repl"] = {
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',
+}