Cleanup config.nodes_of
[check_mk.git] / checks / ibm_svc_enclosurestats
blobbb5bab7cab50c82a3b5e644a66305936b9785705
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 # Example output from agent:
28 # <<<ibm_svc_enclosurestats:sep(58)>>>
29 # 1:power_w:207:218:140410113051
30 # 1:temp_c:22:22:140410113246
31 # 1:temp_f:71:71:140410113246
32 # 2:power_w:126:128:140410113056
33 # 2:temp_c:21:21:140410113246
34 # 2:temp_f:69:69:140410113246
35 # 3:power_w:123:126:140410113041
36 # 3:temp_c:22:22:140410113246
37 # 3:temp_f:71:71:140410113246
38 # 4:power_w:133:138:140410112821
39 # 4:temp_c:22:23:140410112836
40 # 4:temp_f:71:73:140410112836
43 def parse_ibm_svc_enclosurestats(info):
44 dflt_header = [
45 'enclosure_id',
46 'stat_name',
47 'stat_current',
48 'stat_peak',
49 'stat_peak_time',
51 parsed = {}
52 for id_, rows in parse_ibm_svc_with_header(info, dflt_header).iteritems():
53 for data in rows:
54 try:
55 stat_current = int(data['stat_current'])
56 except ValueError:
57 continue
58 parsed.setdefault(id_, {}).setdefault(data['stat_name'], stat_current)
59 return parsed
62 # .--temperature---------------------------------------------------------.
63 # | _ _ |
64 # | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
65 # | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \ |
66 # | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
67 # | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
68 # | |_| |
69 # '----------------------------------------------------------------------'
71 factory_settings["ibm_svc_enclosurestats_temperature_default_levels"] = {"levels": (35, 40)}
74 def inventory_ibm_svc_enclosurestats_temp(info):
75 for enclosure_id, data in parse_ibm_svc_enclosurestats(info).iteritems():
76 if "temp_c" in data:
77 yield enclosure_id, {}
80 def check_ibm_svc_enclosurestats_temp(item, params, info):
81 parsed = parse_ibm_svc_enclosurestats(info)
82 data = parsed.get(item)
83 if data is None:
84 return
85 return check_temperature(data['temp_c'], params, "ibm_svc_enclosurestats_%s" % item)
88 check_info["ibm_svc_enclosurestats.temp"] = {
89 "check_function": check_ibm_svc_enclosurestats_temp,
90 "inventory_function": inventory_ibm_svc_enclosurestats_temp,
91 "service_description": "Temperature Enclosure %s",
92 "has_perfdata": True,
93 "group": "temperature",
94 "includes": ["ibm_svc.include", "temperature.include"],
95 'default_levels_variable': "ibm_svc_enclosurestats_temperature_default_levels"
99 # .--power---------------------------------------------------------------.
100 # | |
101 # | _ __ _____ _____ _ __ |
102 # | | '_ \ / _ \ \ /\ / / _ \ '__| |
103 # | | |_) | (_) \ V V / __/ | |
104 # | | .__/ \___/ \_/\_/ \___|_| |
105 # | |_| |
106 # '----------------------------------------------------------------------'
109 def inventory_ibm_svc_enclosurestats_power(info):
110 for enclosure_id, data in parse_ibm_svc_enclosurestats(info).iteritems():
111 if "power_w" in data:
112 yield enclosure_id, {}
115 def check_ibm_svc_enclosurestats_power(item, _no_params, info):
116 parsed = parse_ibm_svc_enclosurestats(info)
117 data = parsed.get(item)
118 if data is None:
119 return
120 stat_current = data['power_w']
121 return 0, "%s Watt" % stat_current, [('power', stat_current)]
124 check_info["ibm_svc_enclosurestats.power"] = {
125 "check_function": check_ibm_svc_enclosurestats_power,
126 "inventory_function": inventory_ibm_svc_enclosurestats_power,
127 "service_description": "Power Enclosure %s",
128 "includes": ["ibm_svc.include"],
129 "has_perfdata": True,