Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / dell_powerconnect_temp
blobd91310989e18643175b0f6c690be576f2eee3dd1
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:
28 # .1.3.6.1.4.1.89.53.15.1.9.1 = INTEGER: 42
29 # .1.3.6.1.4.1.89.53.15.1.10.1 = INTEGER: ok(1)
31 # Temperature is in Celcius by default.
32 # Tested with Dell PowerConnect 5448 and 5424 models.
34 factory_settings["dell_powerconnect_temp_default_values"] = {
35 "levels": (35, 40),
39 def parse_dell_powerconnect_temp(info):
40 try:
41 temp_str, dev_status = info[0]
42 except (IndexError, ValueError):
43 return None
44 try:
45 temp = float(temp_str)
46 except ValueError:
47 temp = None
48 return temp, {
49 '1': 'OK',
50 '2': 'unavailable',
51 '3': 'non operational',
52 }.get(dev_status, "unknown[%s]" % dev_status)
55 def inventory_dell_powerconnect_temp(checkname, parsed):
56 if parsed:
57 return [("Ambient", {})]
60 def check_dell_powerconnect_temp(_no_item, params, parsed):
61 if parsed is None:
62 return
64 temp, dev_state_readable = parsed
65 if dev_state_readable == "OK":
66 state = 0
67 elif dev_state_readable == "unavailable":
68 state = 1
69 elif dev_state_readable == "non operational":
70 state = 2
71 else:
72 state = 3
74 if temp is None:
75 return state, "Status: %s" % dev_state_readable
76 return check_temperature(
77 temp, params, "dell_powerconnect", dev_status=state, dev_status_name=dev_state_readable)
80 check_info["dell_powerconnect_temp"] = {
81 "parse_function": parse_dell_powerconnect_temp,
82 "check_function": check_dell_powerconnect_temp,
83 "inventory_function": inventory_dell_powerconnect_temp,
84 "service_description": "Temperature %s",
85 "default_levels_variable": "dell_powerconnect_temp_default_values",
86 "has_perfdata": True,
87 "snmp_info": (
88 ".1.3.6.1.4.1.89.53.15.1",
90 "9", # RADLAN-Physicaldescription-MIB::rlPhdUnitEnvParamTempSensorValue
91 "10" # RADLAN-Physicaldescription-MIB::rlPhdUnitEnvParamTempSensorStatus
92 ]),
93 "snmp_scan_function":
94 lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.674.10895"),
95 "group": "temperature",
96 "includes": ["temperature.include"]