Module: check_mk
Branch: master
Commit: 8cb19c2d6a9a21f115925daa4702099869fbb510
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8cb19c2d6a9a21…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Sep 3 10:17:16 2015 +0200
#2574 FIX postfix_mailq: speed up agent part on FreeBSD
---
.werks/2574 | 9 +++++++++
ChangeLog | 1 +
agents/check_mk_agent.freebsd | 19 +++++++++++++++----
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/.werks/2574 b/.werks/2574
new file mode 100644
index 0000000..805e66c
--- /dev/null
+++ b/.werks/2574
@@ -0,0 +1,9 @@
+Title: postfix_mailq: speed up agent part on FreeBSD
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i3
+Date: 1441268204
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index c0bc7c6..e0c2284 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -152,6 +152,7 @@
* 2547 FIX: mysql mysql_capacity mysql_ping mysql_slave: Fixed broken service
discovery when instance id is empty...
* 2564 FIX: logins: missing manpage
* 2575 FIX: cpu.loads: Fix exception in displaying parameters for CPU load check...
+ * 2574 FIX: postfix_mailq: speed up agent part on FreeBSD
Multisite:
* 2385 SEC: Fixed possible reflected XSS on all GUI pages where users can produce
unhandled exceptions...
diff --git a/agents/check_mk_agent.freebsd b/agents/check_mk_agent.freebsd
index e35aded..096b538 100755
--- a/agents/check_mk_agent.freebsd
+++ b/agents/check_mk_agent.freebsd
@@ -317,12 +317,23 @@ netstat -na | awk ' /^tcp/ { c[$6]++; } END { for (x in c) {
print x, c[x]; } }'
# Only handle the last 6 lines (includes the summary line at the bottom and
# the last message in the queue. The last message is not used at the moment
# but it could be used to get the timestamp of the last message.
-if which mailq >/dev/null 2>&1 && getent passwd postfix >/dev/null
2>&1; then
- echo '<<<postfix_mailq>>>'
- mailq | tail -n 6
+if type postconf >/dev/null ; then
+ echo '<<<postfix_mailq>>>'
+ 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
fi
-#Check status of qmail mailqueue
+# Check status of qmail mailqueue
if type qmail-qstat >/dev/null
then
echo "<<<qmail_stats>>>"