X-Git-Url: http://git.sven.stormbind.net/?a=blobdiff_plain;f=zabbixhelper%2Fmailstat.sh;fp=zabbixhelper%2Fmailstat.sh;h=f1a1c6fa1c7f8d6d8a729d6cc444f99cf391fd56;hb=8e9fb924b34bb14a0ce4475b03853d4b526abc33;hp=0000000000000000000000000000000000000000;hpb=f6212ef7560173401ad51bafbbca45c73917a8d9;p=sven%2Fscripts.git

diff --git a/zabbixhelper/mailstat.sh b/zabbixhelper/mailstat.sh
new file mode 100644
index 0000000..f1a1c6f
--- /dev/null
+++ b/zabbixhelper/mailstat.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Collect some mail stats from Postfix for Zabbix.
+# sven@timegate.de - 2010-05-17
+
+VERSION=0.2
+
+qdir=`/usr/sbin/postconf -h queue_directory`
+
+while getopts ":idsh" opt; do
+    case $opt in
+        d)
+        find $qdir/deferred -type f -print | wc -l | awk '{print $1}'
+        ;;
+	i)
+	find $qdir/incoming $qdir/active $qdir/maildrop -type f -print|wc -l|awk '{print $1}'
+        ;;
+	s)
+	echo $(( \
+	    $(du -bs /var/opt/mailhome|cut -f1) + \
+	    $(du -bs /home/sven/Maildir|cut -f1) + \
+	    ))
+	;;
+        h)
+        echo "Mailq stats $VERSION"
+        echo "Usage:"
+        echo "-d Outputs number of mails in the deferred queue"
+        echo "-i Outputs number of mails in the incoming, active and maildrop queue"
+	echo "-s Total size of the most used Maildir folders in bytes"
+        echo "-h Print this help"
+        exit 1
+        ;;
+        \?)
+        echo "Unknown option: -$OPTARG"
+        echo "Try -h to get help"
+        exit 1
+        ;;
+    esac
+done