GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / supermicro
blob7a58ebc08ec8e0dface4a8611765c6471f6edfdc
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 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 # .1.3.6.1.4.1.10876.2.1.1.1.1.2.1 Fan1 Fan Speed
28 # .1.3.6.1.4.1.10876.2.1.1.1.1.2.2 Fan2 Fan Speed
29 # ...
30 # .1.3.6.1.4.1.10876.2.1.1.1.1.2.6 Vcore Voltage
31 # .1.3.6.1.4.1.10876.2.1.1.1.1.2.7 CPU VTT Voltage
32 # .1.3.6.1.4.1.10876.2.1.1.1.1.3.1 0
33 # .1.3.6.1.4.1.10876.2.1.1.1.1.3.2 0
34 # ...
35 # .1.3.6.1.4.1.10876.2.1.1.1.1.3.6 1
36 # .1.3.6.1.4.1.10876.2.1.1.1.1.3.7 1
37 # .1.3.6.1.4.1.10876.2.1.1.1.1.4.1 3760
38 # .1.3.6.1.4.1.10876.2.1.1.1.1.4.2 1909
39 # ...
40 # .1.3.6.1.4.1.10876.2.1.1.1.1.4.6 1080
41 # .1.3.6.1.4.1.10876.2.1.1.1.1.4.7 1056
42 # ...
43 # .1.3.6.1.4.1.10876.2.1.1.1.1.5.6 1488
44 # .1.3.6.1.4.1.10876.2.1.1.1.1.5.7 1344
45 # .1.3.6.1.4.1.10876.2.1.1.1.1.6.1 291
46 # .1.3.6.1.4.1.10876.2.1.1.1.1.6.2 291
47 # ...
48 # .1.3.6.1.4.1.10876.2.1.1.1.1.11.1 RPM
49 # .1.3.6.1.4.1.10876.2.1.1.1.1.11.2 RPM
50 # ...
51 # .1.3.6.1.4.1.10876.2.1.1.1.1.11.6 mV
52 # .1.3.6.1.4.1.10876.2.1.1.1.1.11.7 mV
53 # .1.3.6.1.4.1.10876.2.1.1.1.1.12.1 0
54 # .1.3.6.1.4.1.10876.2.1.1.1.1.12.2 0
55 # ...
56 # .1.3.6.1.4.1.10876.2.1.1.1.1.12.6 0
57 # .1.3.6.1.4.1.10876.2.1.1.1.1.12.7 0
58 # .1.3.6.1.4.1.10876.2.2 0
59 # .1.3.6.1.4.1.10876.2.3 No problem.
62 # .--Health--------------------------------------------------------------.
63 # | _ _ _ _ _ |
64 # | | | | | ___ __ _| | |_| |__ |
65 # | | |_| |/ _ \/ _` | | __| '_ \ |
66 # | | _ | __/ (_| | | |_| | | | |
67 # | |_| |_|\___|\__,_|_|\__|_| |_| |
68 # | |
69 # '----------------------------------------------------------------------'
72 def inventory_supermicro_health(info):
73 if info[1]:
74 return [(None, None)]
77 def check_supermicro_health(_no_item, _no_params, info):
78 return int(info[1][0][0]), info[1][0][1]
81 check_info['supermicro'] = {
82 'check_function': check_supermicro_health,
83 'inventory_function': inventory_supermicro_health,
84 'service_description': "Overall Hardware Health",
85 'snmp_scan_function': lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.311.1.1.3.1.2",
86 'snmp_info': [
88 ".1.3.6.1.4.1.10876.2.1.1.1.1",
90 2, # smHealthMonitorName
91 3, # smHealthMonitorType
92 4, # smHealthMonitorReading
93 5, # smHealthMonitorHighLimit
94 6, # smHealthMonitorLowLimit
95 11, # smHealthMonitorReadingUnit
96 12, # smHealthMonitorStatus
97 ]),
99 ".1.3.6.1.4.1.10876.2",
101 2, # smHealthAllinoneStatus
102 3, # smHealthAllinoneMsg
105 ".1.3.6.1.4.1.10876.100.1.4.1",
107 1, # diskSerialNumber
108 2, # diskName
110 ]), # diskSmartStatus
115 # .--Sensors-------------------------------------------------------------.
116 # | ____ |
117 # | / ___| ___ _ __ ___ ___ _ __ ___ |
118 # | \___ \ / _ \ '_ \/ __|/ _ \| '__/ __| |
119 # | ___) | __/ | | \__ \ (_) | | \__ \ |
120 # | |____/ \___|_| |_|___/\___/|_| |___/ |
121 # | |
122 # '----------------------------------------------------------------------'
125 def inventory_supermicro_sensors(info):
126 for name, _sensor_type, _reading, _high, _low, _unit, _status in info[0]:
127 yield name, None
130 def check_supermicro_sensors(item, _no_params, info):
131 class Type(object):
132 Fan, Voltage, Temperature, Status = ('0', '1', '2', '3')
134 def worst_status(*args):
135 order = [0, 1, 3, 2]
136 return sorted(args, key=lambda x: order[x], reverse=True)[0]
138 def expect_order(*args):
139 return max(
140 [abs(x[0] - x[1][0]) for x in enumerate(sorted(enumerate(args), key=lambda x: x[1]))])
142 for name, sensor_type, reading, high, low, unit, dev_status in info[0]:
143 if name == item:
144 reading = float(reading)
145 dev_status = int(dev_status)
147 crit_upper = warn_upper = None
148 status_high = status_low = 0
149 if high:
150 crit_upper = float(high)
151 warn_upper = crit_upper * 0.95
152 status_high = expect_order(reading, warn_upper, crit_upper)
153 if low:
154 crit_lower = float(low)
155 warn_lower = crit_lower * 1.05
156 status_low = expect_order(crit_lower, warn_lower, reading)
158 perfvar = None
160 # normalize values depending on sensor type
161 if sensor_type == Type.Temperature:
162 unit = u%s" % unit
163 perfvar = "temp"
164 elif sensor_type == Type.Voltage:
165 if unit == "mV":
166 reading, warn_upper, crit_upper =\
167 [x / 1000.0 for x in (reading, warn_upper, crit_upper)]
168 unit = "V"
169 perfvar = "voltage"
170 elif sensor_type == Type.Status:
171 reading = "State %d" % int(reading)
172 unit = ""
174 perfdata = []
176 if perfvar:
177 if crit_upper is not None:
178 perfdata = [(perfvar, reading, warn_upper, crit_upper)]
179 else:
180 perfdata = [(perfvar, reading)]
182 return (worst_status(status_high, status_low, dev_status), "%s%s" % (reading, unit),
183 perfdata)
186 check_info['supermicro.sensors'] = {
187 'check_function': check_supermicro_sensors,
188 'inventory_function': inventory_supermicro_sensors,
189 'service_description': "Sensor %s",
190 'has_perfdata': True,
194 # .--SMART---------------------------------------------------------------.
195 # | ____ __ __ _ ____ _____ |
196 # | / ___|| \/ | / \ | _ \_ _| |
197 # | \___ \| |\/| | / _ \ | |_) || | |
198 # | ___) | | | |/ ___ \| _ < | | |
199 # | |____/|_| |_/_/ \_\_| \_\|_| |
200 # | |
201 # '----------------------------------------------------------------------'
204 def format_item_supermicro_smart(name):
205 return name.replace(r"\\\\.\\", "")
208 def inventory_supermicro_smart(info):
209 for _serial, name, _status in info[2]:
210 yield format_item_supermicro_smart(name), None
213 def check_supermicro_smart(item, _no_params, info):
214 # note (only status 0 (OK) and 2 (Crit) are documented.
215 # status 3 appears to indicate "unknown" as observed by a user.
216 # It's likely - but not verified - that status 1 would indicate a non-
217 # critical problem if it's used at all)
218 status_map = {"0": "Healthy", "1": "Warning", "2": "Critical", "3": "Unknown"}
219 for serial, name, status in info[2]:
220 if format_item_supermicro_smart(name) == item:
221 return int(status), "(S/N %s) %s" % (serial, status_map[status])
224 check_info['supermicro.smart'] = {
225 'check_function': check_supermicro_smart,
226 'inventory_function': inventory_supermicro_smart,
227 'service_description': "SMART Health %s",
228 'has_perfdata': True,