• Home
  • Free Stuff
  • About
  • Contact

Zimbra Tips : Script to Check Mailbox Usage for Each User

February 12, 2014

Yesterday,  a friend of mine  asked me how to take all  data usage for each Zimbra user  for information and reporting purpose. Actually, all information about how many  mailboxes usages for each user on Zimbra Mail Server,  can be seen on the  Zimbra Admin | Server Statistics | Mailbox Quota.

zimbra-logoYou can see total quota and the quota already in use for each user. Although quite informative, it is not really flexible if we would like to use the data for other purposes. We must re-write the existing information or make a screenshot which will be difficult to be done if Zimbra has a large account.

To resolve this issue, we can utilize  Zimbra CLI and then create a small script  to find out how many mailboxes and the total quota usage for each user. Here’s an example of the command line :

su – zimbra

zmmailbox -z -m ahmad.iman@excellent.co.id gms

Command Line to see the total mailboxes

su - zimbra
zmprov ga vivianchow@excellent.co.id | grep zimbraMailQuota

From the  above example, we can create a simple script to looping all user mailbox and retrieve information about mailbox quota

vi /srv/quota-used.sh

paste the following code to the file you just created

#!/bin/bash
echo "Username           Total Quota         Usage"

zmprov -l gaa | while read ACCOUNT
 do
        QUOTA_TOTAL=`zmprov ga ${ACCOUNT} | grep "zimbraMailQuota" | cut -d ":" -f2`
        QUOTA_USAGE=`zmmailbox -z -m ${ACCOUNT} gms`
        echo "${ACCOUNT}    ${QUOTA_TOTAL}    ${QUOTA_USAGE}"
done

give executable permissions and run by using Zimbra permission

chmod +x /srv/quota-used.sh
su - zimbra
sh /srv/quota-used.sh

The above script  can be modified so that the result can be opened as csv file. Good luck and hopely it can be useful 😀 . 

CLIMail ServerZimbra
Share

Linux

Masim "Vavai" Sugianto
Traveller, Open Source Enthusiast & Book Lover. Works as Independent Worker & Self-Employer.

3 Comments


Peter Sullivan
February 12, 2014 at 17:53
Reply

Thanks for the information I am have obtained all the information from my mail software.



Josue Valtrick
May 7, 2015 at 20:31
Reply

Script adjust for print in MB Quota and in order.

#!/bin/bash
echo “Username Total Quota Usage”

zmprov -l gaa | sort | while read ACCOUNT
do
QUOTA_TOTAL=`zmprov ga ${ACCOUNT} | grep “zimbraMailQuota” | cut -d “:” -f2`
QUOTA_TOTAL1=$(echo $QUOTA_TOTAL/1024 | bc)
QUOTA_TOTAL2=$(echo $QUOTA_TOTAL1/1024 | bc)
QUOTA_USAGE=`zmmailbox -z -m ${ACCOUNT} gms`
echo “${ACCOUNT} ${QUOTA_TOTAL2} ${QUOTA_USAGE}”
done



ash
June 5, 2015 at 06:23
Reply

#!/bin/bash
all_account=`zmprov -l gaa`;
for account in ${all_account}
do
mb_size=`zmmailbox -z -m ${account} gms`;
echo “Mailbox size of ${account} = ${mb_size}”;
done



Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Recent Posts

    • Januari 2021 Portfolio Update
    • December 2020 Portfolio Update
    • After a While
    • Life goes On : Farming
    • Pursuing FIRE in Indonesia : Are You Prepared For A Recession?
    • VirtualBox Error Kernel Driver not Installed (rc=-1908) on Zorin OS 15.2
    • ZorinOS on Intel NUC Hades Canyon Series NUC817HVK
    • Banana Farm
    • Zorin OS 15.2 Ultimate
    • Haraka and LDAP Authentication with Zimbra



© Copyright LetsBlog Theme Demo - Theme by ThemeGoods