Module: check_mk
Branch: master
Commit: 096cbe11022cde2f183b89bcb725e6546ac942e6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=096cbe11022cde…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Oct 25 14:21:55 2015 +0100
heartbeat_crm: code cleanup, get rid of import datetime
---
checks/heartbeat_crm | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/checks/heartbeat_crm b/checks/heartbeat_crm
index cbd943b..c82cd7b 100644
--- a/checks/heartbeat_crm
+++ b/checks/heartbeat_crm
@@ -42,8 +42,6 @@
# resource_slapmaster (ocf::heartbeat:OpenLDAP): Started mwp
# resource_slapslave (ocf::heartbeat:OpenLDAP): Started smwp
-import datetime
-
# Nails down the DC to the node which is the DC during inventory. The check
# will report CRITICAL when another node becomes the DC during later checks.
# If set to "False" the check will be passed.
@@ -87,6 +85,17 @@ def heartbeat_crm_parse_general(info):
num_resources = int(line[0])
return (last_updated, dc, num_nodes, num_resources)
+
+# .--CRM-----------------------------------------------------------------.
+# | ____ ____ __ __ |
+# | / ___| _ \| \/ | |
+# | | | | |_) | |\/| | |
+# | | |___| _ <| | | | |
+# | \____|_| \_\_| |_| |
+# | |
+# +----------------------------------------------------------------------+
+# | |
+# '----------------------------------------------------------------------'
def inventory_heartbeat_crm(info):
# Use these lines to gather the inventory and perform this check:
# ============
@@ -130,11 +139,11 @@ def check_heartbeat_crm(item, params, info):
# Check the freshness of the crm_mon output and terminate with CRITICAL
# when too old information are found
- dt = int(datetime.datetime(*time.strptime(last_updated, '%a %b %d %H:%M:%S
%Y')[:6]).strftime("%s"))
+ dt = time.mktime(time.strptime(last_updated, '%a %b %d %H:%M:%S %Y'))
now = time.time()
delta = now - dt
if delta > params['max_age']:
- return 3, 'Ignoring reported data (Status output too old: %d secs)' %
delta
+ return 3, 'Ignoring reported data (Status output too old: %s)' %
get_age_human_readable(delta)
output = ''
status = 0
@@ -164,6 +173,7 @@ def check_heartbeat_crm(item, params, info):
return (status, output.rstrip(', '))
+
check_info["heartbeat_crm"] = {
'check_function' : check_heartbeat_crm,
'inventory_function' : inventory_heartbeat_crm,
@@ -172,6 +182,7 @@ check_info["heartbeat_crm"] = {
'default_levels_variable' : 'heartbeat_crm_default_levels',
}
+
def heartbeat_crm_parse_resources(info):
blockStart = False
resources = {}
@@ -216,6 +227,17 @@ def heartbeat_crm_parse_resources(info):
return resources
+
+#.
+# .--Resources-----------------------------------------------------------.
+# | ____ |
+# | | _ \ ___ ___ ___ _ _ _ __ ___ ___ ___ |
+# | | |_) / _ \/ __|/ _ \| | | | '__/ __/ _ \/ __| |
+# | | _ < __/\__ \ (_) | |_| | | | (_| __/\__ \ |
+# | |_| \_\___||___/\___/ \__,_|_| \___\___||___/ |
+# | |
+# '----------------------------------------------------------------------'
+
def inventory_heartbeat_crm_resources(info):
# Full list of resources:
# Resource Group: group_slapmaster
@@ -235,6 +257,7 @@ def inventory_heartbeat_crm_resources(info):
inventory.append((name, None))
return inventory
+
def check_heartbeat_crm_resources(item, target_node, info):
output = ''
status = 0
@@ -248,8 +271,11 @@ def check_heartbeat_crm_resources(item, target_node, info):
output += ' (Expected node: %s (!!))' % target_node
output += ', '
+ if not output:
+ output = "no resources found"
return (status, output.rstrip(', '))
+
check_info["heartbeat_crm.resources"] = {
'check_function' : check_heartbeat_crm_resources,
'inventory_function' : inventory_heartbeat_crm_resources,