Module: check_mk
Branch: master
Commit: a6f6ac86655a50630f81860f02cc2c14f6ae8736
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a6f6ac86655a50…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Oct 7 09:50:08 2016 +0200
3911 if: each operational state can now be mapped to a check state
---
.werks/3911 | 9 +++++++++
ChangeLog | 1 +
checks/if.include | 24 +++++++++++++++++-------
web/plugins/wato/check_parameters.py | 11 +++++++++++
4 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/.werks/3911 b/.werks/3911
new file mode 100644
index 0000000..4638c5e
--- /dev/null
+++ b/.werks/3911
@@ -0,0 +1,9 @@
+Title: if: each operational state can now be mapped to a check state
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i2
+Date: 1475826564
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index f657cb1..3a201eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
Checks & Agents:
* 3841 cups_queues: thresholds are now configurable in WATO...
* 3910 oracle_instance: noarchivelog can now be ignored
+ * 3911 if: each operational state can now be mapped to a check state
* 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/if.include b/checks/if.include
index a2e42e7..5751c22 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -576,7 +576,8 @@ def check_if_common_single(item, params, info, force_counter_wrap =
False,
targetspeed = params.get("speed")
assumed_speed_in = params.get("assumed_speed_in")
assumed_speed_out = params.get("assumed_speed_out")
- targetstate = params.get("state")
+ targetstates = params.get("state")
+ map_operstates = dict(params.get("map_operstates", []))
average = params.get("average")
unit = params.get("unit") in ["Bit",
"bit"] and "Bit" or "B"
unit_multiplier = unit == "Bit" and 8.0 or 1.0
@@ -668,14 +669,23 @@ def check_if_common_single(item, params, info, force_counter_wrap =
False,
infotext = "%son %s: " % ( infotext, node )
state = 0
-
- if targetstate and \
- (ifOperStatus != targetstate
- and not (type(targetstate) in [ list, tuple ] and ifOperStatus in
targetstate)):
+ infotext += "(%s)" % ifOperStatusName
+ if targetstates and \
+ (ifOperStatus != targetstates
+ and not (type(targetstates) in [ list, tuple ] and ifOperStatus in
targetstates)):
state = 2
- infotext += "(%s)(!!) " % ifOperStatusName
+
+ if map_operstates and ifOperStatus in map_operstates:
+ state = map_operstates[ifOperStatus]
+
+ if state == 1:
+ infotext += "(!) "
+ elif state == 2:
+ infotext += "(!!) "
+ elif state == 3:
+ infotext += "(?) "
else:
- infotext += "(%s) " % ifOperStatusName
+ infotext += " "
if group_members:
infotext = infotext[:-1] # remove last space
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index a45a1f5..1ca9b8b 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -5912,6 +5912,17 @@ register_check_parameters(
none_label = _("ignore"),
negate = True)
),
+ ( "map_operstates",
+ ListOf(
+ Tuple(
+ orientation = "horizontal",
+ elements = [
+ DropdownChoice(choices =
dict_choices(defines.interface_oper_states())),
+ MonitoringState()
+ ]),
+ title = _('Map operational states'),
+ )
+ ),
( "assumed_speed_in",
OptionalDropdownChoice(
title = _("Assumed input speed"),