Module: check_mk
Branch: master
Commit: 0bd3b269b54c24ea2323b32fb8e9a0247f9c35b3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0bd3b269b54c24…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Mon Jan 19 15:56:50 2015 +0100
lnx_thermal: Now supports setting levels.
---
checks/lnx_thermal | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/checks/lnx_thermal b/checks/lnx_thermal
index b2c8322..2297bcb 100644
--- a/checks/lnx_thermal
+++ b/checks/lnx_thermal
@@ -36,9 +36,10 @@
# thermal_zone1 pkg-temp-0 44000 0 passive 0 passive
def inventory_lnx_thermal(info):
- return [ (l[0].replace('thermal_zone', ''), None) for l in info ]
+ return [ (l[0].replace('thermal_zone', 'Zone '), None) for l in info
]
-def check_lnx_thermal(item, _no_params, info):
+
+def check_lnx_thermal(item, params, info):
for line in info:
if line[0].replace('thermal_zone', '') == item:
# ['thermal_zone0', 'enabled', 'acpitz',
'51000', '90000', 'critical', '79000', 'passive']
@@ -55,32 +56,40 @@ def check_lnx_thermal(item, _no_params, info):
pass # -> regular line
# convert values from millidegree
- cur = int(line[3]) / 1000
+ temp = int(line[3]) / 1000
# parse trip points
+ dev_warn = None
+ dev_crit = None
if len(line) > 4:
trip_points = dict(zip(line[5::2], map(lambda x: int(x) / 1000,
line[4::2])))
for tp_num, (tp_name, level) in enumerate(trip_points.items()):
# ignore active cooling device trip points (means enabling a fan or
similar)
if tp_name == 'active':
continue
- if level != 0 and cur > level:
+ if level != 0:
if tp_name in [ 'hot', 'critical' ]:
- state = max(state, 2)
+ dev_crit = level
else:
- state = max(state, 1)
- tp_reached.append("%s (%d)" % (tp_name, tp_num))
+ dev_warn = level
+
+ # If only one relevant trip point is found, use that for both warn and crit
+ if (dev_warn != None) != (dev_crit != None):
+ dev_warn = dev_crit = min(dev_warn, dev_crit)
+
+ if dev_warn and dev_crit:
+ dev_levels = (dev_warn, dev_crit)
+ else:
+ dev_levels = None
- detail_txt = ''
- if tp_reached:
- detail_txt = ' (Trip Points reached: %s)' % ',
'.join(tp_reached)
+ return check_temperature(temp, params, None, dev_levels)
- return (state, 'Temperature is %d °C%s' % (cur, detail_txt), [ (
'temperature', cur ) ])
- return (3, 'No data found for sensor "thermal_zone%s"' % item)
check_info['lnx_thermal'] = {
"inventory_function" : inventory_lnx_thermal,
"check_function" : check_lnx_thermal,
"service_description" : "Temperature %s",
"has_perfdata" : True,
+ "group" : "temperature",
+ "includes" : [ "temperature.include" ],
}