Module: check_mk
Branch: master
Commit: 0bdb7b5c8d9a0051fa9253c37195cce3139acc0c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0bdb7b5c8d9a00…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Nov 20 09:28:21 2015 +0100
#2844 FIX heartbeat_crm: Fixed problem processing the state of clone set resources
---
.werks/2844 | 10 +++++++++
ChangeLog | 1 +
checks/heartbeat_crm | 59 +++++++++++++++++++++++++++++++-------------------
3 files changed, 48 insertions(+), 22 deletions(-)
diff --git a/.werks/2844 b/.werks/2844
new file mode 100644
index 0000000..ece84dd
--- /dev/null
+++ b/.werks/2844
@@ -0,0 +1,10 @@
+Title: heartbeat_crm: Fixed problem processing the state of clone set resources
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i4
+Date: 1448008073
+
+
diff --git a/ChangeLog b/ChangeLog
index b140801..88fa85e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -93,6 +93,7 @@
* 2712 FIX: winperf_processor: this check no longer requires multiple check cycles
before counters are initialized
* 2796 FIX: apc_symetra_ext_temp: now supports temperatures measured in fahrenheit
* 2837 FIX: hitachi_hnas_temp: fixed ascii decode error, handles degree celsius now
correct
+ * 2844 FIX: heartbeat_crm: Fixed problem processing the state of clone set resources
Multisite:
* 2684 Added icons for downloading agent data / walks of hosts...
diff --git a/checks/heartbeat_crm b/checks/heartbeat_crm
index c82cd7b..b835b8c 100644
--- a/checks/heartbeat_crm
+++ b/checks/heartbeat_crm
@@ -188,42 +188,49 @@ def heartbeat_crm_parse_resources(info):
resources = {}
resource = ''
mode = 'single'
- for line in info:
- if ' '.join(line) == 'Failed actions:':
+ for parts in info:
+ line = " ".join(parts)
+
+ if line == 'Failed actions:':
blockStart = False
- elif not blockStart and ' '.join(line) == 'Full list of
resources:':
+ elif not blockStart and line == 'Full list of resources:':
blockStart = True
elif blockStart:
- if ' '.join(line[0:2]) == 'Resource Group:':
+ if line.startswith('Resource Group:'):
# Resource group
- resources[line[-1]] = []
- resource = line[-1]
+ resources[parts[2]] = []
+ resource = parts[2]
mode = 'resourcegroup'
- elif ' '.join(line[0:2]) == 'Clone Set:':
+ elif line.startswith('Clone Set:'):
# Clone set
- resources[line[-2]] = []
- resource = line[-2]
+ resources[parts[2]] = []
+ resource = parts[2]
mode = 'cloneset'
- elif ' '.join(line[0:2]) == 'Master/Slave Set:':
+ elif line.startswith('Master/Slave Set:'):
# Master/Slave set
- resources[line[-2]] = []
- resource = line[-2]
+ resources[parts[2]] = []
+ resource = parts[2]
mode = 'masterslaveset'
elif line[0] == '_':
+ # Cleanup inconsistent agent output in clone set lines
+ if parts[0] != "_":
+ parts.insert(1, parts[0][1:])
+ parts[0] = "_"
+
# Resource group or set member
if mode == 'resourcegroup':
- resources[resource].append(line[1:])
+ resources[resource].append(parts[1:])
elif mode == 'cloneset':
- if line[1] == 'Started:':
- resources[resource].append([ resource, 'Clone',
'Started', line[3] ])
+ if parts[1] == 'Started:':
+ resources[resource].append([ resource, 'Clone',
'Started', parts[3:-1] ])
elif mode == 'masterslaveset':
- if line[1] == 'Masters:':
- resources[resource].append([ resource, 'Master',
'Started', line[3] ])
- if line[1] == 'Slaves:':
- resources[resource].append([ resource, 'Slave',
'Started', line[3] ])
+ if parts[1] == 'Masters:':
+ resources[resource].append([ resource, 'Master',
'Started', parts[3] ])
+ if parts[1] == 'Slaves:':
+ resources[resource].append([ resource, 'Slave',
'Started', parts[3] ])
else:
# Single resource
- resources[line[0]] = [ line ]
+ resources[parts[0]] = [ parts ]
return resources
@@ -261,8 +268,16 @@ def inventory_heartbeat_crm_resources(info):
def check_heartbeat_crm_resources(item, target_node, info):
output = ''
status = 0
- for resource in [ resources for name, resources in
heartbeat_crm_parse_resources(info).iteritems() if name == item ][0]:
- output += ' '.join(resource)
+
+ resources = None
+ for name, this_resources in heartbeat_crm_parse_resources(info).items():
+ if name == item:
+ resources = this_resources
+ if resources == None:
+ return
+
+ for resource in resources:
+ output += ' '.join([ type(p) == list and repr(p) or p for p in resource
])
if len(resource) == 3 or resource[2] != 'Started':
status = 2
output += ' (Resource is in state "%s" (!!))' %
resource[2]