Module: check_mk
Branch: master
Commit: 5d8641b4635b25362bb1d9e13338086715db5158
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5d8641b4635b25…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Feb 25 17:32:21 2011 +0100
akcp_sensor_temp: handle Fahrenheit and missing degreeraw
---
checks/akcp_sensor_temp | 22 ++++++++++++++--------
checks/decru_temps | 5 +----
modules/check_mk_base.py | 5 +++++
3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/checks/akcp_sensor_temp b/checks/akcp_sensor_temp
index bc404b0..e9c3227 100644
--- a/checks/akcp_sensor_temp
+++ b/checks/akcp_sensor_temp
@@ -25,7 +25,7 @@
# Boston, MA 02110-1301 USA.
# +------------------------------------------------------------------+
-# | This file has been contributed by: |
+# | The initial version of this file has been contributed by: |
# | |
# | Michael Nieporte <Michael.Nieporte(a)uk-essen.de> |
# +------------------------------------------------------------------+
@@ -37,23 +37,29 @@ def inventory_akcp_sensor_temp(checkname, info):
inventory = []
for desc, degree, status, online, degreetype, degreeraw in info:
if online == "1":
- inventory.append( (desc, "",
"akcp_sensor_temp_defaultlevels") )
+ inventory.append( (desc, "akcp_sensor_temp_defaultlevels") )
return inventory
def check_akcp_sensor_temp(item, params, info):
for desc, degree, status, online, degreetype, degreeraw in info:
- if degreetype == "0":
- type = "F"
- else:
- type = "C"
if desc == item:
+ if degreetype == "0":
+ type = "F"
+ else:
+ type = "C"
warn, crit = params
- inttemp = saveint(degreeraw)
- temp = inttemp / 10.0
+ if degreeraw != "":
+ temp = saveint(degreeraw) / 10.0
+ else:
+ temp = float(degree)
if status == "7":
return (3, "UNKNOWN - Sensor Error")
else:
if online == "1":
+ # break temp down to celsius if it had been defined as Fahrenheit.
+ if type == "F":
+ temp = to_celsius(temp)
+ type = "C"
infotext = "%.1f " % temp + type + " (warn/crit at
%.1f/%.1f " % (warn, crit) + type + ")"
perfdata = [ ( "temperature", temp, warn, crit ) ]
if temp >= crit:
diff --git a/checks/decru_temps b/checks/decru_temps
index b9162ab..5cf9863 100644
--- a/checks/decru_temps
+++ b/checks/decru_temps
@@ -24,11 +24,8 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-def to_celsius(f):
- return int(round(float(f) - 32.0 ) * 5.0 / 9.0)
-
def inventory_decru_temps(checkname, info):
- return [ (l[0], l[1] + " Fahrenheit", (to_celsius(int(l[1])) + 4.0,
to_celsius(int(l[1])) + 8.0 ) ) for l in info ]
+ return [ (l[0], (int(to_celsius(int(l[1]))) + 4.0, int(to_celsius(int(l[1]))) + 8.0 )
) for l in info ]
def check_decru_temps(item, params, info):
for temp in info:
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 7bf3e35..4c80f54 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1035,3 +1035,8 @@ def get_nic_speed_human_readable(speed):
pass
return speed
+# Convert Fahrenheit to Celsius
+def to_celsius(f):
+ return round(float(f) - 32.0) * 5.0 / 9.0
+
+