Module: check_mk
Branch: master
Commit: dac47eb37fb6e0e69c3cc592661dc29274937ae4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dac47eb37fb6e0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Oct 8 10:47:54 2015 +0200
#2622 FIX postfix_mailq: Fixed exception when postfix is installed but not configured
properly
---
.werks/2622 | 9 +++++++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 18 ++++++++++--------
checks/postfix_mailq | 4 ++--
4 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/.werks/2622 b/.werks/2622
new file mode 100644
index 0000000..29559e6
--- /dev/null
+++ b/.werks/2622
@@ -0,0 +1,9 @@
+Title: postfix_mailq: Fixed exception when postfix is installed but not configured
properly
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i3
+Date: 1444294041
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 5de5ac4..2cd26f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -213,6 +213,7 @@
* 2653 FIX: winperf_msx_queues: fixed incorrect cancelation of check claiming no
counters were available...
* 2619 FIX: services_summary: Fixed exception on WATO services summary page
* 2654 FIX: logwatch: fixed high memory and cpu usage caused by too many
unacknowledged messages...
+ * 2622 FIX: postfix_mailq: Fixed exception when postfix is installed but not
configured properly
Multisite:
* 2385 SEC: Fixed possible reflected XSS on all GUI pages where users can produce
unhandled exceptions...
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index a0f574c..8fe9dc4 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -502,15 +502,17 @@ fi
#
# we determine the number of mails and their size in several postfix mail queues
if type postconf >/dev/null ; then
- echo '<<<postfix_mailq>>>'
- postfix_queue_dir=$(postconf -h queue_directory)
+ postfix_queue_dir=$(postconf -h queue_directory 2>/dev/null)
- for queue in deferred active
- do
- count=$(find $postfix_queue_dir/$queue -type f | wc -l)
- size=$(du -s $postfix_queue_dir/$queue | awk '{print $1 }')
- echo "QUEUE_${queue} $size $count"
- done
+ if [ -n "$postfix_queue_dir" ]; then
+ echo '<<<postfix_mailq>>>'
+ for queue in deferred active
+ do
+ count=$(find $postfix_queue_dir/$queue -type f | wc -l)
+ size=$(du -s $postfix_queue_dir/$queue | awk '{print $1 }')
+ echo "QUEUE_${queue} $size $count"
+ done
+ fi
elif [ -x /usr/sbin/ssmtp ] ; then
echo '<<<postfix_mailq>>>'
mailq 2>&1 | sed 's/^[^:]*: \(.*\)/\1/' | tail -n 6
diff --git a/checks/postfix_mailq b/checks/postfix_mailq
index f999ccb..35ec9e8 100644
--- a/checks/postfix_mailq
+++ b/checks/postfix_mailq
@@ -95,8 +95,8 @@ 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])
- length = int(line[2])
+ 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"