Module: check_mk
Branch: master
Commit: e7d50ff8e2ca27bab2c509190d75b4029b558c25
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e7d50ff8e2ca27…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Dec 4 12:48:50 2014 +0100
postfix_mailq: small fix for better handling empty queues
---
agents/check_mk_agent.linux | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index b301727..73f103a 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -503,9 +503,15 @@ fi
# but it could be used to get the timestamp of the last message.
if type postconf ; then
echo '<<<postfix_mailq>>>'
- echo -- \
- $(du -kd0 $(postconf -h queue_directory)/deferred | awk '{print $1 }')
Kbytes in \
- $(find $(postconf -h queue_directory)/deferred/. ! -name '?' -print | wc
-l) Requests.
+ postfix_queue_dir=$(postconf -h queue_directory)
+ postfix_count=$(find $postfix_queue_dir/deferred -type f | wc -l)
+ postfix_size=$(du -ks $postfix_queue_dir/deferred | awk '{print $1 }')
+ if [ $postfix_count -gt 0 ]
+ then
+ echo -- $postfix_size Kbytes in $postfix_count Requests.
+ else
+ echo Mail queue is empty
+ fi
elif [ -x /usr/sbin/ssmtp ] ; then
echo '<<<postfix_mailq>>>'
mailq 2>&1 | sed 's/^[^:]*: \(.*\)/\1/' | tail -n 6