Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / aix_hacmp_resources
blob61aa38bfb28f9fcdbe2a57892441844b76b8f30f
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 # <<<aix_hacmp_resources:sep(58)>>>
28 # pdb213rg:ONLINE:pasv0450:non-concurrent:OHN:FNPN:NFB:ignore::: : :::
29 # pdb213rg:OFFLINE:pasv0449:non-concurrent:OHN:FNPN:NFB:ignore::: : :::
30 # pmon01rg:ONLINE:pasv0449:non-concurrent:OHN:FNPN:NFB:ignore::: : :::
31 # pmon01rg:OFFLINE:pasv0450:non-concurrent:OHN:FNPN:NFB:ignore::: : :::
33 # parsed =
34 # {u'pdb213rg': [(u'pasv0450', u'online'), (u'pasv0449', u'offline')],
35 # u'pmon01rg': [(u'pasv0449', u'online'), (u'pasv0450', u'offline')]}
37 factory_settings["aix_hacmp_resources"] = {
38 "expect_online_on": "first",
42 def parse_aix_hacmp_resources(info):
43 parsed = {}
44 for line in info:
45 if line[0] not in parsed:
46 parsed[line[0]] = [(line[2], line[1].lower())]
47 else:
48 parsed[line[0]].append((line[2], line[1].lower()))
50 return parsed
53 def inventory_aix_hacmp_resources(parsed):
54 return [(key, None) for key in parsed]
57 @get_parsed_item_data
58 def check_aix_hacmp_resources(item, params, data):
59 if params is None:
60 expected_behaviour = "first"
61 else:
62 expected_behaviour = params.get("expect_online_on", "first")
64 resource_states = []
65 infotext = ""
66 for node_name, resource_state in data:
67 resource_states.append(resource_state)
68 infotext += "%s on node %s, " % (resource_state, node_name)
70 state = 0
71 if expected_behaviour == "first":
72 if resource_states[0] != "online":
73 state = 2
74 elif expected_behaviour == "any":
75 if not any((resource_state == u"online" for resource_state in resource_states)):
76 state = 2
78 return state, infotext[:-2]
81 check_info['aix_hacmp_resources'] = {
82 'default_levels_variable': "aix_hacmp_resources",
83 'parse_function': parse_aix_hacmp_resources,
84 'inventory_function': inventory_aix_hacmp_resources,
85 'check_function': check_aix_hacmp_resources,
86 'service_description': 'HACMP RG %s',
87 'group': 'hacmp_resources',