Zimbra mailbox usage report

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

SMTP="10.0.0.2"
FROM="user@yourdomain.com"
TO="user@yourdomain.com"
SUB="Mailbox Usages"
MSG="Mailbox Usages"

output="/tmp/accountusage.csv"
domain="yourdomain.com"
SendTo="user@yourdomain.com"

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 " "`

#with status
#echo "$user; `expr $usage / 1024 / 1024`MB; `expr $quota / 1024 / 1024`MB; ($status account)" >> $output

# without status
echo "$user; `expr $usage / 1024 / 1024`MB; `expr $quota / 1024 / 1024`MB" >> $output
done

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

sendemail -q -o tls=no -f $FROM -t $TO -u $SUB -m $MSG -s $SMTP:25 -a $output

Create pem certificate

 Creating a .pem with the Private Key and Entire Trust Chain     Log into your DigiCert Management Console and download your Intermediate (D...

Mais vistos