Mailbox usage report

Mailbox usage report

   KB 3797        Last updated on 2015-07-12  




0.00
(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 usagereport.sh, owned by zimbra.zimbra chmod 755 accountusage.sh

#!/bin/bash
output="/tmp/accountusage"
domain="yourdomainnamehere.com"
SendTo="zimbra_reports@$domain"

rm -f $output
touch $output

server=`zmhostname`
/opt/zimbra/bin/zmprov gqu $server|grep $domain|awk {'print $1" "$3" "$2'}|sort|while read line
do
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
done

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/accountusage.sh

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)

user1@yourdomain.com 5Mb 100Mb (active account)
user2@yourdomain.com 77Mb 100Mb (active account)
user3@yourdomain.com 9Mb 100Mb (closed account)
user4@yourdomain.com 24Mb 100Mb (active account)
etc

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: https://wiki.zimbra.com/index.php?title=Mailbox_usage_report 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