Module: check_mk
Branch: master
Commit: 15de79084458d10f4d11c64c6e9e868dc3f5962f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=15de79084458d1…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Aug 24 17:35:14 2018 +0200
6462 aix_hacmp_resources: Now configurable via WATO
Previously, the check would expect a resource to be online
on the first node. It can now be configured to accept
the resource to be online on any node.
Change-Id: Id5bea8a543ca6c02505e393f3550d2c513718e7c
---
.werks/6462 | 12 ++++++++++
checkman/aix_hacmp_resources | 4 ++--
checks/aix_hacmp_resources | 38 +++++++++++++++++++++++---------
cmk/gui/plugins/wato/check_parameters.py | 26 ++++++++++++++++++++++
4 files changed, 68 insertions(+), 12 deletions(-)
diff --git a/.werks/6462 b/.werks/6462
new file mode 100644
index 0000000..eabc75d
--- /dev/null
+++ b/.werks/6462
@@ -0,0 +1,12 @@
+Title: aix_hacmp_resources: Now configurable via WATO
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1535124865
+Class: feature
+
+Previously, the check would expect a resource to be online
+on the first node. It can now be configured to accept
+the resource to be online on any node.
diff --git a/checkman/aix_hacmp_resources b/checkman/aix_hacmp_resources
index 8f97aba..c4ef5eb 100644
--- a/checkman/aix_hacmp_resources
+++ b/checkman/aix_hacmp_resources
@@ -6,8 +6,8 @@ distribution: check_mk
description:
This check monitors the resource group states on different nodes
of AIX HACMP cluster manager.
- The status will be OK, if the first node reports 'online'. Otherwise
- the status changes to CRIT.
+ The status will be OK, if the first, or any node reports 'online',
+ depending on the configuration. Otherwise the status changes to CRIT.
This check needs the check_mk_agent.aix agent.
diff --git a/checks/aix_hacmp_resources b/checks/aix_hacmp_resources
index d11c54f..b0768bc 100644
--- a/checks/aix_hacmp_resources
+++ b/checks/aix_hacmp_resources
@@ -35,6 +35,10 @@
# {u'pdb213rg': [(u'pasv0450', u'online'), (u'pasv0449',
u'offline')],
# u'pmon01rg': [(u'pasv0449', u'online'), (u'pasv0450',
u'offline')]}
+factory_settings["aix_hacmp_resources"] = {
+ "expect_online_on" : "first",
+}
+
def parse_aix_hacmp_resources(info):
parsed = {}
@@ -54,23 +58,37 @@ def inventory_aix_hacmp_resources(parsed):
def check_aix_hacmp_resources(item, params, parsed):
- if item in parsed:
- resource_stats = []
- infotext = ""
- for node_name, resource_status in parsed[item]:
- resource_stats.append(resource_status)
- infotext += "%s on node %s, " % (resource_status, node_name)
-
- state = 0
- if resource_stats[0] != "online":
+ data = parsed.get(item)
+ if data is None:
+ return
+
+ if params is None:
+ expected_behaviour = "first"
+ else:
+ expected_behaviour = params.get("expect_online_on", "first")
+
+ resource_states = []
+ infotext = ""
+ for node_name, resource_state in parsed[item]:
+ resource_states.append(resource_state)
+ infotext += "%s on node %s, " % (resource_state, node_name)
+
+ state = 0
+ if expected_behaviour == "first":
+ if resource_states[0] != "online":
+ state = 2
+ elif expected_behaviour == "any":
+ if not any((resource_state == u"online" for resource_state in
resource_states)):
state = 2
- return state, infotext[:-2]
+ return state, infotext[:-2]
check_info['aix_hacmp_resources'] = {
+ 'default_levels_variable' : "aix_hacmp_resources",
'parse_function' : parse_aix_hacmp_resources,
'inventory_function' : inventory_aix_hacmp_resources,
'check_function' : check_aix_hacmp_resources,
'service_description' : 'HACMP RG %s',
+ 'group' : 'hacmp_resources',
}
diff --git a/cmk/gui/plugins/wato/check_parameters.py
b/cmk/gui/plugins/wato/check_parameters.py
index 87d8cdc..25f4835 100755
--- a/cmk/gui/plugins/wato/check_parameters.py
+++ b/cmk/gui/plugins/wato/check_parameters.py
@@ -4792,6 +4792,32 @@ register_check_parameters(
match_type = "dict",
)
+register_check_parameters(
+ subgroup_applications,
+ "hacmp_resources",
+ _("AIX HACMP Resource Groups"),
+ Transform(
+ Dictionary(
+ elements=[
+ (
+ "expect_online_on",
+ DropdownChoice(
+ title=_(u"Expect resource to be online on"),
+ choices=[
+ ("first", _(u"the first node")),
+ ("any", _(u"any node")),
+ ],
+ )
+ ),
+ ],
+ optional_keys=[],
+ ),
+ forth=lambda x: {"expect_online_on":"first"},
+ ),
+ TextAscii(title=_(u"Resource Group")),
+ match_type="first",
+)
+
#.
# .--Environment---------------------------------------------------------.
# | _____ _ _ |