Module: check_mk
Branch: master
Commit: 3dcc0e7bccb786db5f47a73284ad2f3a4ca435f1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3dcc0e7bccb786…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jun 20 13:44:01 2013 +0200
thermal: Added check for linux thermal sensors (e.g. acpi)
---
ChangeLog | 1 +
agents/check_mk_agent.linux | 11 +++++++
checks/thermal | 70 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 2ec8c4d..e1b957b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,7 @@
* cluster hosts: removed agent version output from Check_MK service (this
was misleading for different agent versions on multiple nodes)
* job check: better handling of unexpected agent output
+ * thermal: Added check for linux thermal sensors (e.g. acpi)
Multisite:
* User accounts can now be locked after a specified amount of auth
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 2ef7e6e..724a777 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -462,6 +462,17 @@ if cd /var/lib/check_mk_agent/job; then
head -n -0 -v *
fi
+# Gather thermal information provided e.g. by acpi
+# At the moment only supporting thermal sensors
+if ls /sys/class/thermal/thermal_zone* >/dev/null 2>&1; then
+ echo '<<<thermal>>>'
+ for F in /sys/class/thermal/thermal_zone*; do
+ echo -n "${F##*/} "
+ cat $F/{mode,type,temp,trip_point_*} | tr \\n " "
+ echo
+ done
+fi
+
# MK's Remote Plugin Executor
if [ -e "$MK_CONFDIR/mrpe.cfg" ]
then
diff --git a/checks/thermal b/checks/thermal
new file mode 100644
index 0000000..e9435ee
--- /dev/null
+++ b/checks/thermal
@@ -0,0 +1,70 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+# <<<thermal>>>
+# thermal_zone0 enabled acpitz 57000 127000 critical
+# thermal_zone1 enabled acpitz 65000 100000 critical 95500 passive
+
+# <<<thermal>>>
+# thermal_zone0 enabled acpitz 47000 90000 critical 79000 passive
+
+def inventory_thermal(info):
+ return [ (l[0].replace('thermal_zone', ''), None) for l in info ]
+
+def check_thermal(item, params, info):
+ for line in info:
+ if line[0].replace('thermal_zone', '') == item:
+ # ['thermal_zone0', 'enabled', 'acpitz',
'51000', '90000', 'critical', '79000', 'passive']
+ state = 0
+ tp_reached = []
+
+ # convert values from millidegree
+ cur = saveint(line[3]) / 1000
+
+ # parse trip points
+ if len(line) > 4:
+ trip_points = dict(zip(line[5::2], map(lambda x: saveint(x) / 1000,
line[4::2])))
+ for tp_num, (tp_name, level) in enumerate(trip_points.items()):
+ if cur > level:
+ if tp_name in [ 'hot', 'critical' ]:
+ state = max(state, 2)
+ else:
+ state = max(state, 1)
+ tp_reached.append("%s (%d)" % (tp_name, tp_num))
+
+ detail_txt = ''
+ if tp_reached:
+ detail_txt = ' (Trip Points reached: %s)' % ',
'.join(tp_reached)
+
+ return (state, 'Temperature is %dC%s' % (cur, detail_txt), [ (
'temperature', cur ) ])
+ return (3, 'No data found for sensor "thermal_zone%s"' % item)
+
+check_info['thermal'] = {
+ "inventory_function" : inventory_thermal,
+ "check_function" : check_thermal,
+ "service_description" : "Thermal Sensor %s",
+ "has_perfdata" : True,
+}