Module: check_mk
Branch: master
Commit: f8f31804a037068b66b908d73d5e28482df08833
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f8f31804a03706…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed May 9 16:26:42 2018 +0200
6075 FIX fortigate_ipsecvpn: Fixed crash if no parameters are stated
Change-Id: I7cb9aa6954a7b7ba8984ac179584e932229f2e0d
---
.werks/6075 | 10 ++++++++++
checks/fortigate_ipsecvpn | 22 ++++++++++------------
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/.werks/6075 b/.werks/6075
new file mode 100644
index 0000000..fa5e1b4
--- /dev/null
+++ b/.werks/6075
@@ -0,0 +1,10 @@
+Title: fortigate_ipsecvpn: Fixed crash if no parameters are stated
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1525875977
+Class: fix
+
+
diff --git a/checks/fortigate_ipsecvpn b/checks/fortigate_ipsecvpn
index 664204c..63eb3ce 100644
--- a/checks/fortigate_ipsecvpn
+++ b/checks/fortigate_ipsecvpn
@@ -37,9 +37,8 @@ def inventory_fortigate_ipsecvpn(info):
def check_fortigate_ipsecvpn(item, params, info):
if type(params) == tuple:
- params = { "levels" : params }
+ params = {"levels" : params}
- warn, crit = params["levels"]
tunnels_ignore_levels = params.get("tunnels_ignore_levels", [])
tunnels_down = []
@@ -56,22 +55,21 @@ def check_fortigate_ipsecvpn(item, params, info):
num_down_ignored = num_down - num_ignored
num_up = num_total - num_down
- if num_down_ignored >= crit:
- status = 2
- elif num_down_ignored >= warn:
- status = 1
- else:
- status = 0
-
infotext = "Total: %d, Up: %d, Down: %d" % \
(num_total, num_up, num_down)
+ warn, crit = params.get("levels", (None, None))
+ status = 0
+ if crit is not None and num_down_ignored >= crit:
+ status = 2
+ elif warn is not None and num_down_ignored >= warn:
+ status = 1
+ if status:
+ infotext += " (warn/crit at %s/%s)" % (warn, crit)
+
if num_ignored:
infotext += " (ignored: %d)" % num_ignored
- if status > 0:
- infotext += " (warn/crit at %d/%d)" % (warn, crit)
-
if tunnels_down:
infotext += ", Tunnels: %s" % (", ".join(tunnels_down))