]> git.sven.stormbind.net Git - sven/scripts.git/blobdiff - zabbixhelper/mailstat.sh
Import zabbix helper
[sven/scripts.git] / zabbixhelper / mailstat.sh
diff --git a/zabbixhelper/mailstat.sh b/zabbixhelper/mailstat.sh
new file mode 100644 (file)
index 0000000..f1a1c6f
--- /dev/null
@@ -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