How to check mailbox usage of all accounts in Zimbra mail server
This script checks disk usage on a Zimbra mail server. The check mailbox usage script reports the space used by each user, the assigned Quota, and each user’s status. Example output is shown below.
superadmin@ezymailhosting.com - Disk used: 3MB || Quota: 0MB (active account)
superuser@ezymailhosting.com - Disk used: 0MB || Quota: 0MB (closed account)
systemmin@ezymailhosting.com - Disk used: 0MB || Quota: 0MB (closed account)
username@ezymailhosting.com - Disk used: 1MB || Quota: 0MB (active account)
superman@ezymailhosting.com - Disk used: 2MB || Quota: 0MB (closed account)
...
virus-quarantines.sdwxti@ezymailhosting.com - Disk used: 5MB || Quota: 0MB (active account)
============================== total Mailbox usages ================================
Total disk usages: 12MB
Script for checking disk usage on a Zimbra mail server
#!/bin/bash
SUM=0
server=`hostname`
/opt/zimbra/bin/zmprov gqu $server|egrep -v "galsync|spam.|ham."|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 - Disk used: `expr $usage / 1024 / 1024`MB || Quota: `expr $quota / 1024 / 1024`MB ($status account)"
SUM=$((SUM + usage))
echo "${SUM}" > /tmp/tataldiskusage
done
echo "============================== total Mailbox usages ================================"
SUM=`cat /tmp/tataldiskusage`
echo "Total disk usages: `expr $SUM / 1024 / 1024`MB"