Module: check_mk
Branch: master
Commit: d978847ba62acdb6bb19523a2c7952f812b19780
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d978847ba62acd…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Tue Sep 30 12:27:21 2014 +0200
innovaphone.include: Minor code cleanup; ibm_svc_enclosurestats, innovaphone_temp:
Reworked to use include function
---
checks/ibm_svc_enclosurestats | 20 ++++----------------
checks/innovaphone.include | 14 +++++++-------
checks/innovaphone_temp | 4 ++--
3 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/checks/ibm_svc_enclosurestats b/checks/ibm_svc_enclosurestats
index 169065d..ffd29c0 100644
--- a/checks/ibm_svc_enclosurestats
+++ b/checks/ibm_svc_enclosurestats
@@ -52,35 +52,23 @@
ibm_svc_enclosurestats_temperature_default_levels = (35, 40)
def inventory_ibm_svc_enclosurestats_temp(info):
- inventory = []
for enclosure_id, stat_name, stat_current, stat_peak, stat_peak_time in info:
if stat_name == "temp_c":
- inventory.append( (enclosure_id,
"ibm_svc_enclosurestats_temperature_default_levels") )
- return inventory
+ yield enclosure_id,
"ibm_svc_enclosurestats_temperature_default_levels"
def check_ibm_svc_enclosurestats_temp(item, params, info):
- warn, crit = params
- perfdata = []
- status = 0
-
for enclosure_id, stat_name, stat_current, stat_peak, stat_peak_time in info:
if enclosure_id == item and stat_name == "temp_c":
- stat_current = int(stat_current)
- if stat_current > crit:
- status = 2
- elif stat_current > warn:
- status = 1
- perfdata = [ ('temp', str(stat_current)+"C", warn, crit) ]
- return status, "Enclosure %s temperature is %s°C" % (enclosure_id,
stat_current), perfdata
+ return check_temperature(int(stat_current), params)
- return 3, "Temperature for enclosure %s not found in agent output" % item
check_info["ibm_svc_enclosurestats.temp"] = {
"check_function" : check_ibm_svc_enclosurestats_temp,
"inventory_function" : inventory_ibm_svc_enclosurestats_temp,
"service_description" : "Temperature Enclosure %s",
"has_perfdata" : True,
- "group" : "hw_temperature",
+ "group" : "room_temperature",
+ "includes" : [ "temperature.include" ],
}
#.
diff --git a/checks/innovaphone.include b/checks/innovaphone.include
index 56cdf32..03beb2b 100644
--- a/checks/innovaphone.include
+++ b/checks/innovaphone.include
@@ -24,15 +24,15 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-def check_innovaphone( params, info, unit="%", msg=False ):
+def check_innovaphone(params, info, unit="%", msg=False):
warn, crit = params
- current = saveint(info[0][1])
- message = "Current: %d%s" % ( current, unit )
+ current = int(info[0][1])
+ message = "Current: %d%s" % (current, unit)
if msg:
- message += " "+msg
- perf = [ ("usage", current, warn, crit, 0, 100 ) ]
- if current > crit:
+ message += " " + msg
+ perf = [ ("usage", current, warn, crit, 0, 100) ]
+ if current >= crit:
return 2, message, perf
- if current > warn:
+ if current >= warn:
return 1, message, perf
return 0, message, perf
diff --git a/checks/innovaphone_temp b/checks/innovaphone_temp
index d9cd868..57ef671 100644
--- a/checks/innovaphone_temp
+++ b/checks/innovaphone_temp
@@ -30,7 +30,7 @@ def inventory_innovaphone_temp(info):
return [ (None, "innovaphone_temp_default_levels") ]
def check_innovaphone_temp(_no_item, params, info):
- return check_innovaphone(params, info, "°C")
+ return check_temperature(int(info[0][1])), params)
check_info["innovaphone_temp"] = {
"check_function" : check_innovaphone_temp,
@@ -38,6 +38,6 @@ check_info["innovaphone_temp"] = {
"service_description" : "Temperature",
"has_perfdata" : True,
"group" : "hw_single_temperature",
- "include" : ["innovaphone.include"]
+ "include" : [ "temperature.include" ],
}