EzyMailHostingAdministration

How to check mailbox usage of all accounts in Zimbra mail server

Zimbra_LogoThis 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.


[email protected] - Disk used: 3MB ||  Quota: 0MB (active account)
[email protected] - Disk used: 0MB ||  Quota: 0MB (closed account)
[email protected] - Disk used: 0MB ||  Quota: 0MB (closed account)
[email protected] - Disk used: 1MB ||  Quota: 0MB (active account)
[email protected] - Disk used: 2MB ||  Quota: 0MB (closed account)
...
[email protected] - 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"
EOF.← Back to articles