Mailbox usage report

Mailbox usage report

   KB 3797        Last updated on 2015-07-12  

(0 votes)

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! :)

Verified Against: Zimbra Collaboration 7.0, 6.0 Date Created: 04/16/2014
Article ID: Date Modified: 2015-07-12

Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Jump to: navigation, search