]> git.sven.stormbind.net Git - sven/scripts.git/blob - zabbixhelper/mailstat.sh
Import zabbix helper
[sven/scripts.git] / zabbixhelper / mailstat.sh
1 #!/bin/sh
2 # Collect some mail stats from Postfix for Zabbix.
3 # sven@timegate.de - 2010-05-17
4
5 VERSION=0.2
6
7 qdir=`/usr/sbin/postconf -h queue_directory`
8
9 while getopts ":idsh" opt; do
10     case $opt in
11         d)
12         find $qdir/deferred -type f -print | wc -l | awk '{print $1}'
13         ;;
14         i)
15         find $qdir/incoming $qdir/active $qdir/maildrop -type f -print|wc -l|awk '{print $1}'
16         ;;
17         s)
18         echo $(( \
19             $(du -bs /var/opt/mailhome|cut -f1) + \
20             $(du -bs /home/sven/Maildir|cut -f1) + \
21             ))
22         ;;
23         h)
24         echo "Mailq stats $VERSION"
25         echo "Usage:"
26         echo "-d Outputs number of mails in the deferred queue"
27         echo "-i Outputs number of mails in the incoming, active and maildrop queue"
28         echo "-s Total size of the most used Maildir folders in bytes"
29         echo "-h Print this help"
30         exit 1
31         ;;
32         \?)
33         echo "Unknown option: -$OPTARG"
34         echo "Try -h to get help"
35         exit 1
36         ;;
37     esac
38 done