Module: check_mk
Branch: master
Commit: 19e1d4ad0d35af0dc63893ea5c795dccb3ac5bc6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=19e1d4ad0d35af…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Oct 7 13:19:14 2016 +0200
3912 elphase.include: now device states can be mapped to monitoring states
---
.werks/3912 | 9 +++++++++
ChangeLog | 1 +
checks/elphase.include | 15 +++++++++++++++
web/plugins/wato/check_parameters.py | 17 ++++++++++++++++-
4 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/.werks/3912 b/.werks/3912
new file mode 100644
index 0000000..c8857ad
--- /dev/null
+++ b/.werks/3912
@@ -0,0 +1,9 @@
+Title: elphase.include: now device states can be mapped to monitoring states
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i2
+Date: 1475839045
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index cbf207c..4ecdd6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
* 3841 cups_queues: thresholds are now configurable in WATO...
* 3910 oracle_instance: noarchivelog can now be ignored
* 3911 if.include: each operational state can now be mapped to a check state
+ * 3912 elphase.include: now device states can be mapped to monitoring states
* 3894 FIX: mkeventd_status: Fixed bug in case Event Console is not running
* 3907 FIX: oracle_tablespaces: simplyfied free space calculation depending on
version...
* 3819 FIX: windows agent: fixed 2 bugs related to mrpe...
diff --git a/checks/elphase.include b/checks/elphase.include
index fe450ab..fa0e32d 100644
--- a/checks/elphase.include
+++ b/checks/elphase.include
@@ -32,6 +32,7 @@ def inventory_elphase(parsed):
# Parsed has the following form:
# parsed = {
# "Phase 1" : {
+# "device_state" : (1, "warning"), # overall
device state: state, state readable
# "voltage" : (220.17, (1, "Voltage is too low")), # with
device state
# "current" : 12.0, # without device
state
# }
@@ -52,6 +53,20 @@ def check_elphase(item, params, parsed):
if params is None:
params = {}
+ if "device_state" in parsed[item]:
+ device_state, device_state_readable = parsed[item]["device_state"]
+ if params.get("map_device_states", []):
+ device_state_params = dict(params["map_device_states"])
+ if device_state in device_state_params:
+ state = device_state_params[device_state]
+ elif device_state_readable in device_state_params:
+ state = device_state_params[device_state_readable]
+ else:
+ state = 0
+ else:
+ state = device_state
+ yield state, "Device status: %s(%s)" % (device_state_readable,
device_state)
+
for what, title, unit, bound, factor in [
( "voltage", "Voltage", " V",
Bounds.Lower, 1),
( "current", "Current", " A",
Bounds.Upper, 1),
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 1ca9b8b..e2c7056 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -10368,6 +10368,13 @@ register_check_parameters(
Integer(title = _("critical at"), unit = u"%",
default_value = 90),
]
)),
+ ("map_device_states",
+ ListOf(Tuple(
+ elements = [ TextAscii(size=10), MonitoringState() ]),
+ title = _("Map device state"),
+ help = _("Here you can enter either device state number (eg.
from SNMP devices) "
+ "or exact device state name and the related
monitoring state."),
+ )),
]),
TextAscii(
title = _("Output Name"),
@@ -10383,7 +10390,15 @@ register_check_parameters(
help = _("This rule allows you to specify levels for the voltage, current,
power "
"and apparent power of your device. The levels will only be applied
if the device "
"actually supplies values for these parameters."),
- elements = phase_elements,
+ elements = phase_elements + [
+ ("map_device_states",
+ ListOf(Tuple(
+ elements = [ TextAscii(size=10), MonitoringState() ]),
+ title = _("Map device state"),
+ help = _("Here you can enter either device state number (eg.
from SNMP devices) "
+ "or exact device state name and the related
monitoring state."),
+ )),
+ ],
),
TextAscii(
title = _("Input Name"),