Cleanup config.nodes_of
[check_mk.git] / checks / aix_hacmp_resources
blobf588159fda41d1482cf1737b51f9314f27815130
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 joined_line = " ".join(line)
46 if 'There is no cluster definition' in joined_line or 'Status of the RSCT subsystems' in joined_line:
47 continue
48 parsed.setdefault(line[0], []).append((line[2], line[1].lower()))
49 return parsed
52 def inventory_aix_hacmp_resources(parsed):
53 return [(key, None) for key in parsed]
56 @get_parsed_item_data
57 def check_aix_hacmp_resources(item, params, data):
58 if params is None:
59 expected_behaviour = "first"
60 else:
61 expected_behaviour = params.get("expect_online_on", "first")
63 resource_states = []
64 infotext = ""
65 for node_name, resource_state in data:
66 resource_states.append(resource_state)
67 infotext += "%s on node %s, " % (resource_state, node_name)
69 state = 0
70 if expected_behaviour == "first":
71 if resource_states[0] != "online":
72 state = 2
73 elif expected_behaviour == "any":
74 if not any((resource_state == u"online" for resource_state in resource_states)):
75 state = 2
77 return state, infotext[:-2]
80 check_info['aix_hacmp_resources'] = {
81 'default_levels_variable': "aix_hacmp_resources",
82 'parse_function': parse_aix_hacmp_resources,
83 'inventory_function': inventory_aix_hacmp_resources,
84 'check_function': check_aix_hacmp_resources,
85 'service_description': 'HACMP RG %s',
86 'group': 'hacmp_resources',