Module: check_mk
Branch: master
Commit: c3c245149525f757ec2f51c1c907ef3cc1f671a7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c3c245149525f7…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Fri Jun 1 17:08:00 2012 +0200
Added hwg_temp check
---
checks/hwg_temp | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 90 insertions(+), 0 deletions(-)
diff --git a/checks/hwg_temp b/checks/hwg_temp
new file mode 100644
index 0000000..3447ee4
--- /dev/null
+++ b/checks/hwg_temp
@@ -0,0 +1,90 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2010 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.
+
+hwg_temp_defaultlevels = (23, 25)
+
+def check_hwg_temp(item, params, info):
+ warn, crit = params
+ status_text = {
+ "0" : "Invalid",
+ "1" : "Normal",
+ "2" : "Out Of Range Low",
+ "3" : "Out Of Range High",
+ "4" : "Alarm Low",
+ "5" : "Alarm High",
+ }
+ unit_text = {
+ "0" : "unknown",
+ "1" : "°C",
+ "2" : "°F",
+ "3" : "°K",
+ "4" : "%",
+ }
+ for line in info:
+ if line[0] == item:
+ descr, status, current, current_m, unit = line[1:]
+ current_state = saveint(current_m)/10
+
+ state = 0
+ if current_state >= crit:
+ state = 2
+ elif current_state >= warn:
+ state = 1
+ elif status in (4, 2):
+ state = 1
+ elif status == 3:
+ state = 2
+
+ perfdata = [ ("temp", current, warn, crit, 0 ) ]
+ unit = unit_text.get(unit)
+ status = status_text.get(status, "UNKOWN")
+ return(state, nagios_state_names[state] + " - %s at %s%s (warn/crit at
%s%s/%s%s), Status is %s" % \
+ (descr, current, unit, warn, unit, crit, unit, status), perfdata)
+
+ return (3, "UNKNOWN - Sensor %s not found in SNMP data %s" % (item) )
+
+check_info['hwg_temp'] = {
+ "check_function" : check_hwg_temp,
+ "inventory_function" : lambda info: [ (line[0], hwg_temp_defaultlevels )
for line in info if int(line[2]) != 0] ,
+ "service_description" : "Temperature %s",
+ "has_perfdata" : True,
+ "snmp_info" : (".1.3.6.1.4.1.21796.4.1.3", [# sensors index
(1-2)
+ "1.1",
+ # sensor name string
+ "1.2",
+ # unit state: 0=Invalid, 1=Normal,
2=OutOfRangeLo, 3=OutOfRangeHi, 4=AlarmLo, 5=AlarmHi
+ "1.3",
+ # current value string
+ "1.4",
+ # current value*10 integer
+ "1.5",
+ # sensor unit integer 0=unknown, 1=°C,
2=°F, 3=°K, 4=%
+ "1.7",
+ ]),
+ "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.1.0") ==
'"HWg-STE"',
+ "group" : "hw_temperature",
+}
+