Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / checks / bintec_sensors
blobc5b417ebf9a348b57703caa59e877e2827535b41
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.
28 def bintec_sensors_scan(oid):
29 return oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.272.4")
32 bintec_sensors_info = (
33 ".1.3.6.1.4.1.272.4.17.7.1.1.1",
35 2, # sensorNumber
36 3, # sensorDescr
37 4, # sensorType
38 5, # sensorValue
39 7, # sensorMeasurementUnit
42 # .--fans----------------------------------------------------------------.
43 # | __ |
44 # | / _| __ _ _ __ ___ |
45 # | | |_ / _` | '_ \/ __| |
46 # | | _| (_| | | | \__ \ |
47 # | |_| \__,_|_| |_|___/ |
48 # | |
49 # '----------------------------------------------------------------------'
51 factory_settings["bintec_sensors_fan_default_levels"] = {
52 "lower": (2000, 1000),
56 def inventory_bintec_sensors_fan(info):
57 inventory = []
58 for _sensor_id, sensor_descr, sensor_type, _sensor_value, _sensor_unit in info:
59 if sensor_type == "2":
60 inventory.append((sensor_descr, {}))
61 return inventory
64 def check_bintec_sensors_fan(item, params, info):
65 for _sensor_id, sensor_descr, _sensor_type, sensor_value, _sensor_unit in info:
66 if sensor_descr == item:
67 return check_fan(int(sensor_value), params)
70 check_info["bintec_sensors.fan"] = {
71 "check_function": check_bintec_sensors_fan,
72 "inventory_function": inventory_bintec_sensors_fan,
73 "service_description": "%s",
74 "snmp_info": bintec_sensors_info,
75 "snmp_scan_function": bintec_sensors_scan,
76 "has_perfdata": True,
77 "default_levels_variable": "bintec_sensors_fan_default_levels",
78 "group": "hw_fans",
79 "includes": ["fan.include"],
83 # .--temp----------------------------------------------------------------.
84 # | _ |
85 # | | |_ ___ _ __ ___ _ __ |
86 # | | __/ _ \ '_ ` _ \| '_ \ |
87 # | | || __/ | | | | | |_) | |
88 # | \__\___|_| |_| |_| .__/ |
89 # | |_| |
90 # '----------------------------------------------------------------------'
92 factory_settings["bintec_sensors_temp_default_levels"] = {"levels": (35, 40)}
95 def inventory_bintec_sensors_temp(info):
96 for _sensor_id, sensor_descr, sensor_type, _sensor_value, _sensor_unit in info:
97 if sensor_type == "1":
98 yield sensor_descr, {}
101 def check_bintec_sensors_temp(item, params, info):
102 for _sensor_id, sensor_descr, _sensor_type, sensor_value, _sensor_unit in info:
103 if sensor_descr == item:
104 return check_temperature(int(sensor_value), params, "bintec_sensors_%s" % item)
106 return 3, "Sensor not found in SNMP data"
109 check_info["bintec_sensors.temp"] = {
110 "check_function": check_bintec_sensors_temp,
111 "inventory_function": inventory_bintec_sensors_temp,
112 "service_description": "Temperature %s",
113 "group": "temperature",
114 "has_perfdata": True,
115 "snmp_info": bintec_sensors_info,
116 "snmp_scan_function": bintec_sensors_scan,
117 "includes": ["temperature.include"],
118 "default_levels_variable": "bintec_sensors_temp_default_levels"
122 # .--voltage-------------------------------------------------------------.
123 # | _ _ |
124 # | __ _____ | | |_ __ _ __ _ ___ |
125 # | \ \ / / _ \| | __/ _` |/ _` |/ _ \ |
126 # | \ V / (_) | | || (_| | (_| | __/ |
127 # | \_/ \___/|_|\__\__,_|\__, |\___| |
128 # | |___/ |
129 # '----------------------------------------------------------------------'
132 def inventory_bintec_sensors_voltage(info):
133 inventory = []
134 for _sensor_id, sensor_descr, sensor_type, _sensor_value, _sensor_unit in info:
135 if sensor_type == "3":
136 inventory.append((sensor_descr, None))
137 return inventory
140 def check_bintec_sensors_voltage(item, _no_params, info):
141 for _sensor_id, sensor_descr, _sensor_type, sensor_value, _sensor_unit in info:
142 if sensor_descr == item:
143 sensor_value = int(sensor_value) / 1000.0
145 message = "%s is at %s V" % (sensor_descr, sensor_value)
146 perfdata = [("voltage", str(sensor_value) + "V")]
148 return 0, message, perfdata
150 return 3, "Sensor %s not found" % item
153 check_info["bintec_sensors.voltage"] = {
154 "check_function": check_bintec_sensors_voltage,
155 "inventory_function": inventory_bintec_sensors_voltage,
156 "service_description": "Voltage %s",
157 "has_perfdata": True,
158 "snmp_info": bintec_sensors_info,
159 "snmp_scan_function": bintec_sensors_scan,