Cleanup config.nodes_of
[check_mk.git] / checks / netapp_api_temp
blobddf066a9f70d0ee90454daa6283d23ca05dfeaed
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 # <<<netapp_api_temp:sep(9)>>>
28 # temp-sensor-list 11 temp-sensor-current-condition normal_temperature_range temp-sensor-is-ambient true temp-sensor-low-warning 5 temp-sensor-hi-warning 40 temp-sensor-hi-critical 42 temp-sensor-current-temperature 24 temp-sensor-element-no 1 temp-sensor-low-critical 0 temp-sensor-is-error false
31 def inventory_netapp_api_temp(parsed):
32 shelfs = {x.split(".")[0] for x in parsed.keys()}
33 for shelf in shelfs:
34 yield "Internal Shelf %s" % shelf, {}
35 yield "Ambient Shelf %s" % shelf, {}
38 def check_netapp_api_temp(item, params, parsed):
39 is_ambient = "true" if item.startswith("Ambient") else "false"
41 sensors = []
42 for name, values in parsed.items():
43 if name.split(".")[0] == item.split()[-1]:
44 if values.get("temp-sensor-is-not-installed") != "true" and\
45 is_ambient == values.get("temp-sensor-is-ambient"):
46 sensors.append(values)
48 sensorlist = []
49 for sensor in sensors:
50 current_temp = int(sensor["temp-sensor-current-temperature"])
51 sensor_no = sensor["temp-sensor-element-no"]
52 warn_low = int(sensor["temp-sensor-low-warning"])
53 crit_low = int(sensor["temp-sensor-low-critical"])
54 warn_high = int(sensor["temp-sensor-hi-warning"])
55 crit_high = int(sensor["temp-sensor-hi-critical"])
57 kwargs = {
58 "dev_levels": (warn_high, crit_high),
59 "dev_levels_lower": (warn_low, crit_low),
62 sensorlist.append((item.split()[-1] + "/" + sensor_no, current_temp, kwargs))
64 if not sensorlist:
65 return 0, "No temperature sensors assigned to this filer"
66 return check_temperature_list(sensorlist, params, "netapp_api_temp_%s" % item)
69 check_info["netapp_api_temp"] = {
70 'check_function': check_netapp_api_temp,
71 'inventory_function': inventory_netapp_api_temp,
72 'parse_function': lambda info: netapp_api_parse_lines(
73 info, custom_keys=["temp-sensor-list", "temp-sensor-element-no"]),
74 'has_perfdata': True,
75 'group': "temperature",
76 'service_description': 'Temperature %s',
77 'includes': ["netapp_api.include", "temperature.include"]