how to show email accounts with max used space

johannes

Verified User
Joined
Feb 18, 2007
Messages
847
Hi,

i`m sorry if i did not found this in the forum, maybe its here and someone can direct me.

I need to know which emailaccounts for one given user are using the most space. Example: i have 1 user with 300mb, 30 domains and he has some 50 emailaccounts and cant remember wich one is using all the space. I have already added some more free space (1,5gb), but i`m not able to tell my customer which of his emailaccounts is using all the space.
I dont want to click through all domains and emailaccounts in DA, is there maybe another way?

Thanks for any hints!
 
Hello,

To list all virtual accounts with disk usage use this command:

Code:
for d in `cat /etc/virtual/domains`; do for e in `cat /etc/virtual/${d}/passwd 2>/dev/null | cut -d\: -f1`; do doveadm quota get -u $e@$d 2>&1 | grep STORAGE | awk '{system("echo -ne "$2)}' && echo " "$e@$d ; done; done;

or put the code into /root/email_disk_usage.sh:

Code:
#!/bin/bash
for d in `cat /etc/virtual/domains`;
do
        for e in `cat /etc/virtual/${d}/passwd 2>/dev/null | cut -d\: -f1`;
        do
                doveadm quota get -u $e@$d 2>&1 | grep STORAGE | awk '{system("echo -ne "$2)}' && echo " "$e@$d ;
        done;
done;

and run as

Code:
/root/email_disk_usage.sh | sort -rn | head

to list TOP disk usage on all domains of all users.

Code:
/root/email_disk_usage.sh | grep @domain.com | sort -rn | head

to list TOP disk usage on one domain (replace domain.com with your domain).
 
Last edited:
Thanks for the script Alex! :)

Shall i ask you to to implement all additional things inside it without need to remember the additional commands?

Also, there is a way to prevent that this script count the domain pointer email to prevent false duplicates?

Regards
 
I'm glad you like it. Yes, that's a good idea. I was already thinking of it, and I will do it.
 
Hello Zeiter,

thank you for your help. I did tried the script and it seems its listing only the pop accounts. I did found in the meantime the big emailaccounts from my customer, which are used as imap, but in the script output they are listed as 0 (zero) bytes.
Is it possible to get the imap mailaccounts also in this listing?

Thank you very much!
 
I dont think there is difference between dovecot and pop since it is using dovecot admin commands to check them.

Also, another little hint, maybe provide data in GB/MB (depending on the size) would be "clearer" on reading ;)

Regards
 
Johannes,

Dovecot does not split email accounts into POP and IMAP accounts. They are the same if to look at how it is organised on the server-side. What the script does not list is system email accounts (which get created when you add a new user account).

Did you check them from directadmin? What do you see in Directadmin for those accounts?
 
Hello Alex,

hmm thats strange. In DA it shows correctly the 2 big mailboxes with together about 1gb, but with 0 in the script output, please see att. screenshots.
Andrea told me he would take a look into this a little bit later, i will hold you updated what is coming out.usage in DA.jpgscriptoutput.jpg
 
OK,

try to recalculate quotas with:

Code:
for d in `cat /etc/virtual/domains`; do for e in `cat /etc/virtual/${d}/passwd 2>/dev/null | cut -d\: -f1`; do doveadm quota recalc -u $e@$d ; done; done;

and then try the first scripts again.
 
Yes it works, that did the trick, it shows now the correct size. I added it into your script on top and now it calculates each time if running.
Thank you very much, Alex!
 
Hi again,

with latest command i actually have (many) this error:

Error: Couldn't load plugin /usr/lib/dovecot/doveadm/lib10_doveadm_zlib_plugin.so: Module is for different ABI version 2.1.16 (we have 2.2.ABIv16(2.2.16))


Any hint?

Regards
 
I have no much information on the files. I had the same issue when writing the script and commands.

I removed:

/usr/lib/dovecot/doveadm/lib10_doveadm_zlib_plugin.*

from my server. There should be 3 files: lib10_doveadm_zlib_plugin.a, lib10_doveadm_zlib_plugin.la and lib10_doveadm_zlib_plugin.so.
In my case the three were the oldest ones, something 1-3 years old. When building dovecot with custombuild new versions of the files do not get created. So I guess they are not necessary any longer.
 
Thanks for script Alex!

Are there any ways to show all spaces from all emails (in resellers packages)?

Btw, I have a question more, if I limited on sending is 1000 on DA but on my web script then I am sending out with 1500 emails, so 500 emails will not be sent or in queue?
 
Do you mean to limit an output for domains of users of only one reseller as an opposite to all users of a server?
 
Back
Top