Module: check_mk
Branch: master
Commit: ade63010177a37a013ca06f3d6e46364dabe4150
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ade63010177a37…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed May 10 10:21:33 2017 +0200
4649 fortigate_ipsecvpn: tunnels which are down can now be ignored during levels
calculation
Change-Id: Ife3ea6dadff9827534c282228da5ede3248d7be2
---
.werks/4649 | 10 +++++++
checks/fortigate_ipsecvpn | 58 ++++++++++++++++++++++--------------
web/plugins/wato/check_parameters.py | 1 +
3 files changed, 47 insertions(+), 22 deletions(-)
diff --git a/.werks/4649 b/.werks/4649
new file mode 100644
index 0000000..b78cfeb
--- /dev/null
+++ b/.werks/4649
@@ -0,0 +1,10 @@
+Title: fortigate_ipsecvpn: tunnels which are down can now be ignored during levels
calculation
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1494404461
+Class: feature
+
+
diff --git a/checks/fortigate_ipsecvpn b/checks/fortigate_ipsecvpn
index 7019ffa..664204c 100644
--- a/checks/fortigate_ipsecvpn
+++ b/checks/fortigate_ipsecvpn
@@ -25,7 +25,9 @@
# Boston, MA 02110-1301 USA.
-fortigate_ipsecvpn_default_levels = (1, 2)
+factory_settings['fortigate_ipsecvpn_default_levels'] = {
+ "levels" : (1, 2),
+}
def inventory_fortigate_ipsecvpn(info):
@@ -34,47 +36,59 @@ def inventory_fortigate_ipsecvpn(info):
def check_fortigate_ipsecvpn(item, params, info):
-
if type(params) == tuple:
params = { "levels" : params }
- ent_status_map = {
- "1": "down",
- "2": "up"
- }
-
warn, crit = params["levels"]
-
- tunnels_down = [p2name for p2name, ent_status in info
- if ent_status_map[ent_status] == "down"]
-
- num_down = len(tunnels_down)
- num_total = len(info)
- num_up = num_total - num_down
-
- if num_down >= crit:
+ tunnels_ignore_levels = params.get("tunnels_ignore_levels", [])
+
+ tunnels_down = []
+ tunnels_ignored = []
+ for p2name, ent_status in info:
+ if ent_status == "1":
+ tunnels_down.append(p2name)
+ if p2name in tunnels_ignore_levels:
+ tunnels_ignored.append(p2name)
+
+ num_total = len(info)
+ num_down = len(tunnels_down)
+ num_ignored = len(tunnels_ignored)
+ num_down_ignored = num_down - num_ignored
+ num_up = num_total - num_down
+
+ if num_down_ignored >= crit:
status = 2
- elif num_down >= warn:
+ elif num_down_ignored >= warn:
status = 1
else:
status = 0
- infotext = "Active/Configured: %d/%d" % (num_total - num_down, num_total)
+ infotext = "Total: %d, Up: %d, Down: %d" % \
+ (num_total, num_up, num_down)
+
+ if num_ignored:
+ infotext += " (ignored: %d)" % num_ignored
+
+ if status > 0:
+ infotext += " (warn/crit at %d/%d)" % (warn, crit)
+
if tunnels_down:
- infotext += ", down: " + ", ".join(tunnels_down)
+ infotext += ", Tunnels: %s" % (", ".join(tunnels_down))
return status, infotext, [('active_vpn_tunnels', num_up, '',
'', 0, num_total)]
check_info["fortigate_ipsecvpn"] = {
- "default_levels_variable" : "fortigate_ipsecvpn",
"inventory_function" : inventory_fortigate_ipsecvpn,
"check_function" : check_fortigate_ipsecvpn,
"service_description" : "VPN IPSec Tunnels",
"has_perfdata" : True,
"snmp_scan_function" : lambda oid:
".1.3.6.1.4.1.12356.101.1" in oid(".1.3.6.1.2.1.1.2.0"),
- "snmp_info" : (".1.3.6.1.4.1.12356.101.12.2.2.1",
[3, # fgVpnTunEntPhase2Name
- 20]), #
fgVpnTunEntStatus
+ "snmp_info" : (".1.3.6.1.4.1.12356.101.12.2.2.1",
[
+ 3, # fgVpnTunEntPhase2Name
+ 20, # fgVpnTunEntStatus
+ ]),
+ "default_levels_variable" :
"fortigate_ipsecvpn_default_levels",
"group" : "ipsecvpn",
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index ac14f9f..5a74dea 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -636,6 +636,7 @@ register_check_parameters(
Integer(title=_("Warning at"), default_value=1),
Integer(title=_("Critical at"), default_value=2),
])),
+ ("tunnels_ignore_levels", ListOfStrings(title = _("Tunnels
which ignore levels")))
],
optional_keys = []
),