Module: check_mk
Branch: master
Commit: 112917107972be6d0db6ad2e46eac92f41789d42
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=112917107972be…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Feb 22 16:06:26 2017 +0100
8750 FIX checkpoint_packets: fixed parameters handling if none are set
Change-Id: I08c25da3e369becc829df916bd82e6a6c64f2d83
---
.werks/8750 | 9 +++++++++
checks/checkpoint_packets | 32 +++++++++++++++++++-------------
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/.werks/8750 b/.werks/8750
new file mode 100644
index 0000000..162a828
--- /dev/null
+++ b/.werks/8750
@@ -0,0 +1,9 @@
+Title: checkpoint_packets: fixed parameters handling if none are set
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.8p18
+Date: 1487775888
+Class: fix
+
+
diff --git a/checks/checkpoint_packets b/checks/checkpoint_packets
index 298fca7..53eb099 100644
--- a/checks/checkpoint_packets
+++ b/checks/checkpoint_packets
@@ -44,24 +44,30 @@ def inventory_checkpoint_packets(info):
def check_checkpoint_packets(_no_item, params, info):
if info:
value = {}
- value["accepted"] = int(info[0][0])
- value["rejected"] = int(info[0][1])
- value["dropped"] = int(info[0][2])
- value["logged"] = int(info[0][3])
+ value["Accepted"] = int(info[0][0])
+ value["Rejected"] = int(info[0][1])
+ value["Dropped"] = int(info[0][2])
+ value["Logged"] = int(info[0][3])
this_time = time.time()
- state = 0
-
for name in value.keys():
- warn, crit = params.get(name, (None, None))
- rate = get_rate(name, this_time, value[name])
+ key = name.lower()
+ if params.get(key) is None:
+ warn, crit = (None, None)
+ else:
+ warn, crit = params[key]
+
+ rate = get_rate(key, this_time, value[name])
infotext = "%s: %.1f pkts/s" % ( name, rate )
- if rate >= crit:
+ state = 0
+ if crit is not None and rate >= crit:
state = 2
- elif rate >= warn:
+ elif warn is not None and rate >= warn:
state = 1
- perfdata = [ (name, rate, warn, crit, 0) ]
- yield state, infotext, perfdata
+ if state:
+ infotext += " (warn/crit at %s/%s pkts/s)" % (warn, crit)
+
+ yield state, infotext, [ (key, rate, warn, crit, 0) ]
check_info["checkpoint_packets"] = {
@@ -72,7 +78,7 @@ check_info["checkpoint_packets"] = {
"group" : "checkpoint_packets",
"snmp_scan_function" : scan_checkpoint,
"default_levels_variable" : "checkpoint_packets_default_levels",
- "snmp_info" : ( ".1.3.6.1.4.1.2620.1.1",
+ "snmp_info" : ( ".1.3.6.1.4.1.2620.1.1",
[ 4, # fwAccepted
5, # fwRejected
6, # fwDropped