How to check mailbox usage of all accounts in Zimbra mail server
Script สำหรับการตรวจสอบการใช้งาน disk บนระบบ Zimbra mail server ซึ่ง script check mailbox usage นี้จะสามารถรายงานจำนวนเนื้อที่ที่แต่ละ user ใช้งานรวมถึงบอกจำนวน Quota ที่ได้ assign ไว้ และสถานะของแต่ละ user อีกด้วย ซึ่งตัวอย่างผลลัพธ์การทำงานสามารถแสดงได้ดังตัวอย่างด้านล่าง
[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 สำหรับการตรวจสอบการใช้งาน disk บนระบบ 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"