Module: check_mk
Branch: master
Commit: f90995d0b53f7dfcd4497d749964a6306fd2e9ef
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f90995d0b53f7d…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed May 31 08:55:15 2017 +0200
Minor cleanup in ehterbox check plugin
Change-Id: If2615e276a654961fbca5b65e8794b25f68d5de1
---
checks/etherbox | 73 ++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 62 insertions(+), 11 deletions(-)
diff --git a/checks/etherbox b/checks/etherbox
index f91651b..371c47a 100644
--- a/checks/etherbox
+++ b/checks/etherbox
@@ -39,12 +39,14 @@
# TODO: insert missing snmp output
+
def etherbox_convert(info):
sensor_data = []
for i in range(0, len(info[1])):
sensor_data.append((info[1][i][1], info[2][i][1], info[3][i][1], info[4][i][1]
))
return sensor_data
+
def inventory_etherbox(info, req_sensor_type):
sensor_data = etherbox_convert(info)
for index, name, sensor_type, value in sensor_data:
@@ -54,6 +56,7 @@ def inventory_etherbox(info, req_sensor_type):
if sensor_type == req_sensor_type:
yield "%s.%s" % (index, sensor_type), None
+
def etherbox_get_sensor(item, item_type, info):
sensor_data = etherbox_convert(info)
item_index, item_type = item.split(".")
@@ -64,6 +67,7 @@ def etherbox_get_sensor(item, item_type, info):
return name, value
raise Exception("Sensor not found")
+
def etherbox_scan(oid):
# Older firmware version of Etherbox do not answer on
# .1.3.6.1.2.1. (sysDescr). Yurks. We need to fetch
@@ -79,6 +83,17 @@ etherbox_info = [
( ".1.3.6.1.4.1.14848.2.1.2.1.5", [ OID_END, '' ]), #
value * 10
]
+
+# .--temperature---------------------------------------------------------.
+# | _ _ |
+# | | |_ ___ _ __ ___ _ __ ___ _ __ __ _| |_ _ _ _ __ ___ |
+# | | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \
|
+# | | || __/ | | | | | |_) | __/ | | (_| | |_| |_| | | | __/ |
+# | \__\___|_| |_| |_| .__/ \___|_| \__,_|\__|\__,_|_| \___| |
+# | |_| |
+# '----------------------------------------------------------------------'
+
+
def check_etherbox_temp(item, params, info):
try:
name, value = etherbox_get_sensor(item, "1", info)
@@ -87,7 +102,8 @@ def check_etherbox_temp(item, params, info):
uom = { "0": "c", "1": "f", "2":
"k" }[info[0][0][0]]
temp = int(value) / 10.0
- return check_temperature(temp, params, "etherbox_temp_%s" % item, uom)
+ state, infotext, perfdata = check_temperature(temp, params,
"etherbox_temp_%s" % item, uom)
+ return state, "[%s] %s" % (name, infotext), perfdata
check_info["etherbox.temp"] = {
@@ -101,6 +117,18 @@ check_info["etherbox.temp"] = {
"includes" : [ "temperature.include" ],
}
+
+#.
+# .--humidity------------------------------------------------------------.
+# | _ _ _ _ _ |
+# | | |__ _ _ _ __ ___ (_) __| (_) |_ _ _ |
+# | | '_ \| | | | '_ ` _ \| |/ _` | | __| | | | |
+# | | | | | |_| | | | | | | | (_| | | |_| |_| | |
+# | |_| |_|\__,_|_| |_| |_|_|\__,_|_|\__|\__, | |
+# | |___/ |
+# '----------------------------------------------------------------------'
+
+
def check_etherbox_humidity(item, params, info):
try:
name, value = etherbox_get_sensor(item, "3", info)
@@ -108,27 +136,28 @@ def check_etherbox_humidity(item, params, info):
return 3, error.message
state = 0
- temp = int(value) / 10.0
+ humid = int(value) / 10.0
levels_info = ""
if params:
crit_low, warn_low, warn_high, crit_high = params
levels_info = " (warn/crit below %.1f/%.1f %%RH / warn/crit at %.1f/%.1f
%%RH )" %\
(crit_low, warn_low, warn_high, crit_high)
- if temp <= crit_low:
+ if humid <= crit_low:
state = 2
- elif temp >= crit_high:
+ elif humid >= crit_high:
state = 2
- elif temp <= warn_low:
+ elif humid <= warn_low:
state = 1
- elif temp >= warn_high:
+ elif humid >= warn_high:
state = 1
else:
crit_low, warn_low, warn_high, crit_high = None, None, None, None
- perfdata = [ ("humidity", temp, crit_low, warn_low, warn_high, crit_high)
]
- infotext = "%s: Humidity %.1f %%RH %s" % (name, temp, levels_info)
+ perfdata = [ ("humidity", humid, crit_low, warn_low, warn_high, crit_high)
]
+ infotext = "[%s] Humidity %.1f %%RH %s" % (name, humid, levels_info)
return (state, infotext, perfdata)
+
check_info["etherbox.humidity"] = {
"check_function" : check_etherbox_humidity,
"inventory_function" : lambda x: inventory_etherbox(x, "3"),
@@ -140,6 +169,17 @@ check_info["etherbox.humidity"] = {
}
+#.
+# .--switch contact------------------------------------------------------.
+# | _ _ _ _ _ |
+# | _____ _(_) |_ ___| |__ ___ ___ _ __ | |_ __ _ ___| |_ |
+# | / __\ \ /\ / / | __/ __| '_ \ / __/ _ \| '_ \| __/ _` |/ __| __| |
+# | \__ \\ V V /| | || (__| | | | | (_| (_) | | | | || (_| | (__| |_ |
+# | |___/ \_/\_/ |_|\__\___|_| |_| \___\___/|_| |_|\__\__,_|\___|\__| |
+# | |
+# '----------------------------------------------------------------------'
+
+
def check_etherbox_switch_contact(item, params, info):
try:
name, value = etherbox_get_sensor(item, "4", info)
@@ -157,7 +197,7 @@ def check_etherbox_switch_contact(item, params, info):
state = 2
extra_info = ", should be %s" % params
- infotext = "%s: Switch contact %s%s" % (name, switch_state, extra_info)
+ infotext = "[%s] Switch contact %s%s" % (name, switch_state, extra_info)
return (state, infotext, perfdata)
check_info["etherbox.switch"] = {
@@ -171,6 +211,17 @@ check_info["etherbox.switch"] = {
}
+#.
+# .--smoke---------------------------------------------------------------.
+# | _ |
+# | ___ _ __ ___ ___ | | _____ |
+# | / __| '_ ` _ \ / _ \| |/ / _ \ |
+# | \__ \ | | | | | (_) | < __/ |
+# | |___/_| |_| |_|\___/|_|\_\___| |
+# | |
+# '----------------------------------------------------------------------'
+
+
def check_etherbox_smoke(item, no_params, info):
try:
name, value = etherbox_get_sensor(item, "6", info)
@@ -184,7 +235,8 @@ def check_etherbox_smoke(item, no_params, info):
extra_info = " - Smoke alarm!"
state = 2
- return (state, "%s: Smoke sensor%s" % (name, extra_info), perfdata)
+ return (state, "[%s] Smoke sensor%s" % (name, extra_info), perfdata)
+
check_info["etherbox.smoke"] = {
"check_function" : check_etherbox_smoke,
@@ -194,4 +246,3 @@ check_info["etherbox.smoke"] = {
"snmp_scan_function" : etherbox_scan,
"snmp_info" : etherbox_info,
}
-