Module: check_mk
Branch: master
Commit: f643b9ccd4ca94f6a0c59c413a9172ab492a7227
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f643b9ccd4ca94…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Apr 10 13:24:37 2018 +0200
5964 FIX sym_brightmail_queues: Fixed ValueError if some queues do not provide all
necessary data
Change-Id: I52fa810ddb595828b5f8802db2acbc4f03296823
---
.werks/5964 | 11 +++++
checks/sym_brightmail_queues | 103 +++++++++++++++++++++++--------------------
2 files changed, 67 insertions(+), 47 deletions(-)
diff --git a/.werks/5964 b/.werks/5964
new file mode 100644
index 0000000..485c7d1
--- /dev/null
+++ b/.werks/5964
@@ -0,0 +1,11 @@
+Title: sym_brightmail_queues: Fixed ValueError if some queues do not provide all
necessary data
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i4
+Date: 1523359396
+
+
diff --git a/checks/sym_brightmail_queues b/checks/sym_brightmail_queues
index 93267dd..49dc821 100644
--- a/checks/sym_brightmail_queues
+++ b/checks/sym_brightmail_queues
@@ -25,7 +25,6 @@
# Boston, MA 02110-1301 USA.
-# Example part from SNMP walk:
# .1.3.6.1.4.1.393.200.130.2.1.2.1 = INTEGER: 1
# .1.3.6.1.4.1.393.200.130.2.1.2.2 = INTEGER: 1
# .1.3.6.1.4.1.393.200.130.2.2.1.1.1.1 = INTEGER: 1
@@ -53,62 +52,71 @@
# .1.3.6.1.4.1.393.200.130.2.2.1.1.8.2 = Gauge32: 0
# .1.3.6.1.4.1.393.200.130.2.2.1.1.8.3 = Gauge32: 0
-# Legacy default
-#brightmail_message_levels = {}
-def inventory_sym_brightmail_queues(info):
- inventory = []
- for line in info:
- inventory.append((line[0], {}))
- return inventory
+def parse_sym_brightmail_queues(info):
+ parsed = {}
+ for descr, connections, dataRate, deferredMessages, \
+ messageRate, queueSize, queuedMessages in info:
+ for k, v in [
+ ("connections", connections),
+ ("dataRate", dataRate),
+ ("deferredMessages", deferredMessages),
+ ("messageRate", messageRate),
+ ("queueSize", queueSize),
+ ("queuedMessages", queuedMessages),
+ ]:
+ try:
+ parsed.setdefault(descr, {}).setdefault(k, int(v))
+ except ValueError:
+ pass
+ return parsed
-def check_sym_brightmail_queues(item, params, info):
- state = 0
+def inventory_sym_brightmail_queues(parsed):
+ for descr in parsed:
+ yield descr, {}
- for line in info:
- if line[0] == item:
- connections, dataRate, deferredMessages, \
- messageRate, queueSize, queuedMessages = line[1:]
- msg = ''
- for label, value, (warn, crit) in [
- ("connections", int(connections),
params.get("connections", (None, None))),
- ("messageRate", int(messageRate),
params.get("messageRate", (None, None))),
- ("dataRate", int(dataRate),
params.get("dataRate", (None, None))),
- ("queuedMessages", int(queuedMessages),
params.get("queuedMessages", (None, None))),
- # Symantec did not document the Unit for the queue. You can still
set
- # some level if you wish.
- ("queuesize", int(queueSize),
params.get("queueSize", (None, None))),
- ("deferredMessages", int(deferredMessages),
params.get("deferredMessages",(None, None))),
- ]:
- single_state = 0
+def check_sym_brightmail_queues(item, params, parsed):
+ if item not in parsed:
+ yield
+ return
- if crit is not None and value >= crit:
- single_state = (max(state, 2))
- elif warn is not None and value >= warn:
- single_state = (max(state, 1))
- state = (max(single_state, state))
- msg += "%s:%d" % (label, value) + "!" * single_state
+ " "
- # Perfdata: maybe one graph per Queue with connections, messageRate,
queuedMessages, deferredMessages
- # and another for queuesize and datarate
+ data = parsed[item]
+ for key, title in [
+ ("connections", "Connections"),
+ ("dataRate", "Data rate"),
+ ("deferredMessages", "Deferred messages"),
+ ("messageRate", "Message rate"),
+ # Symantec did not document the Unit for the queue. You can still set
+ # some level if you wish.
+ ("queueSize", "Queue size"),
+ ("queuedMessages", "Queued messages"),
+ ]:
+ warn, crit = params.get(key, (None, None))
+ value = data.get(key)
+ if value is None:
+ continue
- return (state, msg)
-
-
-
- return (3, "Queue not found in agent output")
+ infotext = "%s: %s" % (title, value)
+ state = 0
+ if crit is not None and crit >= crit:
+ state = 2
+ elif warn is not None and warn >= warn:
+ state = 1
+ if state:
+ infotext += " (warn/crit at %s/%s)" % (warn, crit)
+ yield state, infotext
check_info["sym_brightmail_queues"] = {
- "check_function" : check_sym_brightmail_queues,
- "group" : "sym_brightmail_queues",
- "inventory_function" : inventory_sym_brightmail_queues,
- "service_description" : "Queue %s",
- "snmp_scan_function" : lambda oid: "el5_sms" in
oid(".1.3.6.1.2.1.1.1.0").lower() or \
- "el6" in
oid(".1.3.6.1.2.1.1.1.0").lower(),
- "snmp_info" : (
- ".1.3.6.1.4.1.393.200.130.2", [
+ "parse_function" : parse_sym_brightmail_queues,
+ "inventory_function" : inventory_sym_brightmail_queues,
+ "check_function" : check_sym_brightmail_queues,
+ "service_description" : "Queue %s",
+ "snmp_scan_function" : lambda oid: "el5_sms" in
oid(".1.3.6.1.2.1.1.1.0").lower() or \
+ "el6" in
oid(".1.3.6.1.2.1.1.1.0").lower(),
+ "snmp_info" : (".1.3.6.1.4.1.393.200.130.2", [
"2.1.1.2", # InstanceDescr
"2.1.1.3", # Connections
"2.1.1.4", # dataRate
@@ -117,4 +125,5 @@ check_info["sym_brightmail_queues"] = {
"2.1.1.7", # queueSize
"2.1.1.8", # queuedMessages
]),
+ "group" : "sym_brightmail_queues",
}