Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / oracle_crs_res
blob2d7745fb86a8007bd05f2c027682f570948db73c
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 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 # Original version by Thorsten Bruhns from OPITZ CONSULTING Deutschland GmbH
29 # <<<oracle_crs_res:sep(124)>>>
30 # ezszds8c|NAME=ora.DG_CLUSTER.dg
31 # ezszds8c|TYPE=ora.diskgroup.type
32 # ezszds8c|STATE=ONLINE on ezszds8c
33 # ezszds8c|TARGET=ONLINE
34 # ezszds8c|NAME=ora.I31_ARCH.dg
35 # ezszds8c|TYPE=ora.diskgroup.type
36 # ezszds8c|STATE=ONLINE on ezszds8c
37 # ezszds8c|TARGET=ONLINE
38 # ezszds8c|NAME=ora.I31_DATA.dg
39 # ezszds8c|TYPE=ora.diskgroup.type
40 # ezszds8c|STATE=ONLINE on ezszds8c
41 # ezszds8c|TARGET=ONLINE
42 # ezszds8c|NAME=ora.I31_MLOG.dg
43 # ezszds8c|TYPE=ora.diskgroup.type
44 # ezszds8c|STATE=ONLINE on ezszds8c
45 # ezszds8c|TARGET=ONLINE
46 # ...usw...
49 # Parse output into dict of dicts of dicts:
50 # nodename -> ressource name -> entry
51 # ressource. Example:
52 # { 'ezszds8c' :
53 # { 'ora.I31_ARCH.dg' : {
54 # 'state': 'ONLINE on ezszds9c',
55 # 'target': 'ONLINE',
56 # 'type': 'ora.diskgroup.type'}
57 # }
58 # }
59 # Returns a pair of CRS node name and the former dict
60 def parse_oracle_crs_res(info):
61 crs_nodename = None
62 ressources = {}
63 for nodename, varsetting in info:
64 if nodename == "nodename":
65 crs_nodename = varsetting
66 continue
68 key, value = varsetting.split("=", 1)
69 if key == "NAME":
70 res_name = value
71 entry = {}
72 ressources.setdefault(res_name, {})
73 ressources[res_name][nodename] = entry
74 else:
75 entry[key.lower()] = value
76 return crs_nodename, ressources
79 def inventory_oracle_crs_res(parsed):
80 return [(name, None) for name in parsed[1]]
83 def check_oracle_crs_res(item, _no_params, parsed):
84 _crs_nodename, ressources = parsed
86 # In case of missing information we assume that the clusterware
87 # is not running and we simple skip the result
88 if item not in ressources:
89 if item == 'ora.cssd':
90 yield 2, "Clusterware not running"
91 elif item == 'ora.crsd':
92 yield 2, "Cluster Resource Service Daemon not running!"
93 else:
94 raise MKCounterWrapped(
95 "No ressource details found for %s. Maybe the cssd/crsd is not running" % item)
96 return
98 for nodename, entry in ressources[item].items():
99 resstate = entry["state"].split(' ', 1)[0]
100 restarget = entry["target"]
102 if nodename == "csslocal":
103 infotext = "local: "
104 else:
105 infotext = "on " + nodename + ": "
106 infotext += resstate.lower()
108 if resstate != restarget:
109 state = 2
110 infotext += ", target state %s" % restarget.lower()
111 else:
112 state = 0
113 yield state, infotext
116 check_info['oracle_crs_res'] = {
117 "parse_function": parse_oracle_crs_res,
118 "check_function": check_oracle_crs_res,
119 "inventory_function": inventory_oracle_crs_res,
120 "service_description": "ORA-GI %s Resource",
121 "group": "oracle_crs_res",