Module: check_mk
Branch: master
Commit: 224294ea7f68a20e2a0e908a5a1ca296998ca88b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=224294ea7f68a2…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon May 27 17:29:45 2013 +0200
viprinet_router: Now able to set required target state via rule
---
ChangeLog | 1 +
checkman/viprinet_router | 8 ++++----
checks/viprinet_router | 19 ++++++++++++++++---
web/plugins/wato/check_parameters.py | 24 ++++++++++++++++++++++++
4 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1aeb326..3526f35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
Checks & Agents:
* lnx_if: Fixed crash on missing "Address" field
+ * viprinet_router: Now able to set required target state via rule
1.2.3i1:
Core:
diff --git a/checkman/viprinet_router b/checkman/viprinet_router
index 8b72ba1..da10bc1 100644
--- a/checkman/viprinet_router
+++ b/checkman/viprinet_router
@@ -23,7 +23,7 @@ inventory:
[parameters]
parameters(dict): a dictionary with the optional key
- {"mode"} - specifies the required router mode. The mode can be set to
- {node} / {hub} / {hub_hotspare} / {hub_hotspare_replacing}
- and {inventory} (same mode as detected on inventory).
- If the actual mode differs from this mode a warning is raised
+ {"expect_mode"} - specifies the required router mode. The mode can be set to
+ "0", "1", "2", "3" (mentioned
above) or "inv" which means
+ the same mode as detected during inventory.
+ If the actual mode differs from this mode an error is raised
diff --git a/checks/viprinet_router b/checks/viprinet_router
index ca287b6..39084f4 100644
--- a/checks/viprinet_router
+++ b/checks/viprinet_router
@@ -24,14 +24,26 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-def check_viprinet_router(_no_item, _no_params, info):
+def check_viprinet_router(_no_item, params, info):
router_mode_map = {
"0" : "Node",
"1" : "Hub",
"2" : "Hub running as HotSpare",
"3" : "Hotspare-Hub replacing another router"
}
- mode = router_mode_map.get(info[0][0][0])
+ current_mode = info[0][0][0]
+ mode = router_mode_map.get(current_mode)
+
+ expect_mode = params.get("expect_mode")
+ if expect_mode:
+ # Requires mode found on inventory
+ if expect_mode == "inv":
+ expect_mode = params.get("mode_inv")
+ if expect_mode in router_mode_map:
+ if expect_mode != current_mode:
+ return (2, "Mode '%s' differs from expected mode
'%s'" %
+ ( mode, router_mode_map.get(expect_mode) ))
+
if mode:
return (0, mode)
else:
@@ -39,9 +51,10 @@ def check_viprinet_router(_no_item, _no_params, info):
check_info["viprinet_router"] = {
'check_function' : check_viprinet_router,
- 'inventory_function' : lambda info: len(info) > 0 and [(None, None)] or
[],
+ 'inventory_function' : lambda info: len(info) > 0 and [(None,
{"mode_inv": info[0][0][0]})] or [],
'service_description' : "Router Mode",
'has_perfdata' : False,
+ 'group' : "viprinet_router",
'snmp_info' : (".1.3.6.1.4.1.35424.1.1", [5]),
'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.2.0") in
[".1.3.6.1.4.1.35424"],
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index fb7c8a3..d2cab37 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1008,6 +1008,30 @@ register_check_parameters(
register_check_parameters(
subgroup_networking,
+ "viprinet_router",
+ _("Viprinet router"),
+ Dictionary(
+ elements = [
+ ( "expect_mode",
+ DropdownChoice(
+ title = _("Set expected router mode"),
+ choices = [
+ ( "inv", _("Mode found during inventory") ),
+ ( "0" , _("Node") ),
+ ( "1" , _("Hub") ),
+ ( "2" , _("Hub running as HotSpare") ),
+ ( "3" , _("Hotspare-Hub replacing another
router") ),
+ ]
+ )
+ ),
+ ]
+ ),
+ None,
+ None
+)
+
+register_check_parameters(
+ subgroup_networking,
"tcp_conn_stats_win",
("TCP connection stats (Windows)"),
Dictionary(