--- /dev/null
+#!/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