Mailbox usage report

Revision as of 14:54, 16 August 2010 by Richardteachout (talk | contribs) (Initial Creation page.. hope it helps someone else.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A way to get an emailable report of all mailboxes in a domain, their quota, usage and account status, so a domain admin can review their accounts without having to login to zimbra. (most of this is the same as viewing quota usage in zimbra admin, but this was easier, as it can then be emailed on a schedule)

I saved this file in /opt/zimbra/backup/scripts/ as, owned by zimbra.zimbra chmod 755


rm -f $output
touch $output

/opt/zimbra/bin/zmprov gqu $server|grep $domain|awk {'print $1" "$3" "$2'}|sort|while read line
usage=`echo $line|cut -f2 -d " "`
quota=`echo $line|cut -f3 -d " "`
user=`echo $line|cut -f1 -d " "`
status=`/opt/zimbra/bin/zmprov ga $user | grep  zimbraAccountStatus | cut -f2 -d " "`
echo "$user `expr $usage / 1024 / 1024`Mb `expr $quota / 1024 / 1024`Mb ($status account)" >> $output

cat $output | mail @SendTo -s"Mailbox Usages for $domain"

Then I just setup a cronjob (crontab -e as zimbra user) to run this at 4:01 every monday morning, and email it to them.
1 4 * * 1 /opt/zimbra/backup/scripts/

You could easily modify this to run through each domain on your server, and send a report to each domain, if you wanted (just add another for loop)
The output looks something like this (alphabetically for all users) 5Mb 100Mb (active account) 77Mb 100Mb (active account) 9Mb 100Mb (closed account) 24Mb 100Mb (active account)

They then can at a quick glance, see if there are any users nearing quota, or if a locked/closed account is using too much disk space and should be purged, etc! :)

Jump to: navigation, search