Module: check_mk
Branch: master
Commit: 64202a770bb6e39589d87af3ba6a547dfdfc3110
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=64202a770bb6e3…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 20 16:20:15 2016 +0100
#2909 FIX postfix_mailq: Fixed crash when postfix mailq size can not be read
---
.werks/2909 | 9 +++++++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 3 +++
checks/postfix_mailq | 11 +++++++++--
4 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/.werks/2909 b/.werks/2909
new file mode 100644
index 0000000..4ba8ee1
--- /dev/null
+++ b/.werks/2909
@@ -0,0 +1,9 @@
+Title: postfix_mailq: Fixed crash when postfix mailq size can not be read
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1453302965
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 6448029..611e810 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -195,6 +195,7 @@
* 2891 FIX: mcafee_av_client: fixed wrong params handling after WATO configuration
* 2907 FIX: chrony: Fixed exception in discovery function when daemon is not running
* 2908 FIX: oracle_locks: Fixed handling of ORA- errors as sent from e.g. older AIX
agents
+ * 2909 FIX: postfix_mailq: Fixed crash when postfix mailq size can not be read
Multisite:
* 2684 Added icons for downloading agent data / walks of hosts...
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 516d070..4c03094 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -563,6 +563,9 @@ if type postconf >/dev/null ; then
do
count=$(find $postfix_queue_dir/$queue -type f | wc -l)
size=$(du -s $postfix_queue_dir/$queue | awk '{print $1 }')
+ if [ -z "$size" ]; then
+ size=0
+ fi
echo "QUEUE_${queue} $size $count"
done
fi
diff --git a/checks/postfix_mailq b/checks/postfix_mailq
index 35ec9e8..fb69d6b 100644
--- a/checks/postfix_mailq
+++ b/checks/postfix_mailq
@@ -95,8 +95,15 @@ def check_postfix_mailq(_no_item, params, info):
# new extended version of agent output
if line[0].startswith("QUEUE_"):
queue = line[0].split("_")[1]
- size = int(line[1]) # in bytes
- length = int(line[2]) # number of mails
+
+ # Deal with old agent (pre 1.2.8) which did not send size
+ # infos in case of different error cases
+ if len(line) == 2:
+ size = 0
+ length = int(line[1]) # number of mails
+ else:
+ size = int(line[1]) # in bytes
+ length = int(line[2]) # number of mails
infotext = "%s queue length is %d" % (queue, length)
if queue == "deferred":
length_var = "length"