Module: check_mk
Branch: master
Commit: b23c26f59d49bb007d401533d39e72411f702a96
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b23c26f59d49bb…
Author: Goetz Golla <gg(a)mathias-kettner.de>
Date: Thu Mar 12 23:27:12 2015 +0100
minor code rewrite
---
checks/mbg_lantime.include | 4 ++--
checks/mbg_lantime_ng_fan | 20 +++++++++++---------
checks/mbg_lantime_ng_power | 8 +++++---
checks/mbg_lantime_ng_state | 9 +++++----
4 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/checks/mbg_lantime.include b/checks/mbg_lantime.include
index ecde50a..934e8a8 100644
--- a/checks/mbg_lantime.include
+++ b/checks/mbg_lantime.include
@@ -49,9 +49,9 @@ def check_mbg_lantime_state_common(states, _no_item, params, info):
state = 0
levels_text = ""
warn, crit = params["stratum"]
- if int(stratum) > crit:
+ if int(stratum) >= crit:
state = 2
- elif int(stratum) > warn:
+ elif int(stratum) >= warn:
state = 1
if state != 0:
levels_text = " (warn/crit at %d/%d)" % (warn, crit)
diff --git a/checks/mbg_lantime_ng_fan b/checks/mbg_lantime_ng_fan
index c14f0ce..41405a5 100644
--- a/checks/mbg_lantime_ng_fan
+++ b/checks/mbg_lantime_ng_fan
@@ -31,25 +31,27 @@ def inventory_mbg_lantime_ng_fan(info):
def check_mbg_lantime_ng_fan(item, _no_params, info):
fan_stati = {
- "1": ("on", 0),
- "2": ("off", 2),
+ "1": (0, "on"),
+ "2": (2, "off"),
}
fan_errors = {
- "0": ("not available", 0),
- "1": ("no", 0),
- "2": ("yes", 2),
+ "0": (0, "not available"),
+ "1": (0, "no"),
+ "2": (2, "yes"),
}
for line in info:
- index, status, error = line
+ index, fan_status, fan_error = line
if index == item:
- infotext = "%s, errors: %s" % (fan_stati[status][0],
fan_errors[error][0])
- state = max(fan_stati[status][1], fan_errors[error][1])
+ fan_state, fan_state_name = fan_states[fan_status]
+ error_state, error_name = fan_errors[fan_error]
+ infotext = "%s, errors: %s" % (fan_state_name, error_name)
+ state = max(fan_state, error_state)
return state, infotext
check_info["mbg_lantime_ng_fan"] = {
"check_function" : check_mbg_lantime_ng_fan,
"inventory_function" : inventory_mbg_lantime_ng_fan,
- "service_description" : "Fan",
+ "service_description" : "Fan %s",
"snmp_info" : (".1.3.6.1.4.1.5597.30.0.5.1.2.1", [
1, # mgbLtNgSysFanIndex
2, # mgbLtNgSysFanStatus
diff --git a/checks/mbg_lantime_ng_power b/checks/mbg_lantime_ng_power
index 21d6356..175caf5 100644
--- a/checks/mbg_lantime_ng_power
+++ b/checks/mbg_lantime_ng_power
@@ -35,15 +35,17 @@ def check_mbg_lantime_ng_power(item, _no_params, info):
"1" : ( 2, "down" ),
"2" : ( 0, "up" ),
}
- for index, status in info:
+ for index, power_status in info:
if item == index:
- return power_states[status][0], "Status: %s" %
power_states[status][1]
+ power_state, power_state_name = power_states[power_status]
+ infotext = "Status: %s" % power_state_name
+ return power_state, infotext
check_info["mbg_lantime_ng_power"] = {
"check_function" : check_mbg_lantime_ng_power,
"inventory_function" : inventory_mbg_lantime_ng_power,
- "service_description" : "Power Supply",
+ "service_description" : "Power Supply %s",
"snmp_info" : (".1.3.6.1.4.1.5597.30.0.5.0.2.1", [
1, # MBG-SNMP-LTNG-MIB::mbgLtNgSysPsIndex
2, # MBG-SNMP-LTNG-MIB::mbgLtNgSysPsStatus
diff --git a/checks/mbg_lantime_ng_state b/checks/mbg_lantime_ng_state
index 6c486b5..7ec3dbd 100644
--- a/checks/mbg_lantime_ng_state
+++ b/checks/mbg_lantime_ng_state
@@ -34,10 +34,11 @@ def check_mbg_lantime_ng_state(_no_item, params, info):
'1': (2, 'not synchronized'),
'2': (0, 'synchronized'),
}
- converted_info = info[0]
- #Convert to microseconds
- converted_info[3] = float(converted_info[3]) * 1000
- return check_mbg_lantime_state_common(states, _no_item, params, [converted_info])
+ ntp_state, stratum, refclock_name = info[0][:-1]
+ # Convert to microseconds
+ refclock_offset = float(info[0][-1]) * 1000
+ newinfo = [[ntp_state, stratum, refclock_name, refclock_offset]]
+ return check_mbg_lantime_state_common(states, _no_item, params, newinfo)
check_info["mbg_lantime_ng_state"] = {