Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / cmciii_lcp_water
blob3e05aabda21d4be6a5655307828315c117c5d2a7
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 # Note: The CMCIII checks for Water IN/OUT and similar stuff are
28 # deep and fundamentally broken (such as the implementation of
29 # Rittal). Need to rewrite an make *one* check with subchecks.
31 # [['Fan Unit'],
32 # ['V09.005'],
33 # ['V0000'],
34 # ['OK'],
35 # ['2'],
36 # ['Air-Temperatures'],
37 # ['19.8 \xb0C'],
38 # ['19.0 \xb0C'],
39 # ['18.2 \xb0C'],
40 # ['19.9 \xb0C'],
41 # ['18.9 \xb0C'],
42 # ...
43 # ['Water Unit'],
44 # ['V09.002'],
45 # ['V0000'],
46 # ['OK'],
47 # ['2'],
48 # ['Water-In'],
49 # ['18.2 \xb0C'],
50 # ['50.0 \xb0C'],
51 # ['40.0 \xb0C'],
52 # ...
53 # ]]
56 def parse_cmciii_lcp_water(info):
57 units = {}
58 for line in info:
59 if line[0].endswith(" Unit"):
60 unit_name = line[0].split(" ")[0]
61 unit_lines = []
62 units[unit_name] = unit_lines
63 else:
64 unit_lines.append(line[0])
66 if "Water" in units:
67 return units["Water"]
70 def inventory_cmciii_lcp_water(parsed):
71 return []
74 def check_cmciii_lcp_water(item, params, parsed):
75 # New check: This sensor is handled by cmciii.temp
76 def parse_status(status_name):
77 if status_name.lower() == "ok":
78 return 0
79 elif status_name.lower() == "warning":
80 return 1
81 return 2
83 unit_status_name = parsed[2]
84 yield parse_status(unit_status_name), "Unit: %s" % unit_status_name
86 if item == "IN":
87 lines = parsed[5:12]
88 else:
89 lines = parsed[14:21]
91 # ['18.2 \xb0C', '50.0 \xb0C', '40.0 \xb0C', '13.0 \xb0C', '10.0 \xb0C', '3 %', 'OK']
93 temperatures = [float(x.split()[0]) for x in lines[0:5]]
94 temp = temperatures[0]
95 limits = temperatures[1:]
96 status_name = lines[-1]
98 status, info_text, perf_data = check_temperature(
99 temp,
100 params,
101 "cmciii_lcp_water_" + item,
102 dev_levels=(limits[1], limits[0]),
103 dev_levels_lower=(limits[2], limits[3]),
104 dev_status=parse_status(status_name),
105 dev_status_name=status_name)
107 yield status, "Temperature: " + info_text, perf_data
110 check_info['cmciii_lcp_water'] = {
111 "parse_function" : parse_cmciii_lcp_water,
112 "check_function" : check_cmciii_lcp_water,
113 "inventory_function" : inventory_cmciii_lcp_water,
114 "has_perfdata" : True,
115 "service_description" : "Temperature Water LCP %s",
116 "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.1.0").startswith("Rittal LCP") and \
117 oid(".1.3.6.1.4.1.2606.7.4.2.2.1.3.2.6").startswith("Air.Temperature.DescName"),
118 "snmp_info" : ( '.1.3.6.1.4.1.2606.7.4.2.2.1.10', [2] ),
119 "group" : "temperature",
120 "includes" : [ "temperature.include" ]