Koozali.org: home of the SME Server

Mailbox size contrib?

Offline Drifting

  • ****
  • 431
  • +0/-0
Mailbox size contrib?
« on: December 10, 2014, 09:32:27 AM »
Hi Chaps.

Anyone aware of a simple contrib that would indicate to the local admin or user how much email they are storing? Did a brief google on here but most of the info that came up related to version 7, and currently I run most 8.x

P
Infamy, Infamy, they all have it in for me!

Offline Stefano

  • *
  • 10,839
  • +2/-0
Re: Mailbox size contrib?
« Reply #1 on: December 10, 2014, 09:59:48 AM »
mmmhhh..

something like
Code: [Select]
du -s -m /home/e-smith/files/users/*/Maildir | sort -n -r

in cron?

Code: [Select]
7827    /home/e-smith/files/users/tania/Maildir
6183    /home/e-smith/files/users/roberto/Maildir
2910    /home/e-smith/files/users/gianni/Maildir
499     /home/e-smith/files/users/archivio/Maildir
2       /home/e-smith/files/users/assistenza/Maildir
1       /home/e-smith/files/users/spam/Maildir
1       /home/e-smith/files/users/riunioni/Maildir
1       /home/e-smith/files/users/notspam/Maildir
1       /home/e-smith/files/users/michele/Maildir
1       /home/e-smith/files/users/laura/Maildir
1       /home/e-smith/files/users/katia/Maildir
1       /home/e-smith/files/users/chiara/Maildir

Offline Drifting

  • ****
  • 431
  • +0/-0
Re: Mailbox size contrib?
« Reply #2 on: December 10, 2014, 11:09:17 AM »
Brilliant thank you so much, wished I understood more command line. Note duly made for later use.

Regards P
Infamy, Infamy, they all have it in for me!

Offline Stefano

  • *
  • 10,839
  • +2/-0
Re: Mailbox size contrib?
« Reply #3 on: December 10, 2014, 11:22:59 AM »
Quote
du(1) - Linux man page
Name
du - estimate file space usage
Synopsis
du [OPTION]... [FILE]...
du [OPTION]... --files0-from=F
Description

Summarize disk usage of each FILE, recursively for directories.

-s, --summarize
    display only a total for each argument
-m
    like --block-size=1M

and
Quote
sort(1) - Linux man page
Name
sort - sort lines of text files
Synopsis
sort [OPTION]... [FILE]...
sort [OPTION]... --files0-from=F
Description

Write sorted concatenation of all FILE(s) to standard output.

-n, --numeric-sort
    compare according to string numerical value

-r, --reverse
    reverse the result of comparisons


HTH

Offline ReetP

  • *
  • 3,740
  • +5/-0
Re: Mailbox size contrib?
« Reply #4 on: December 10, 2014, 12:31:50 PM »
Or :

du -h -s /home/e-smith/files/users/*/Maildir | sort -n -r

If you want a human readable format :-)

(ha - quick edit to point out that this doesn't appear to sort correctly. Bug in DU with Gb ?)

Alternatively how about :

http://wiki.contribs.org/Durep
http://wiki.contribs.org/Diskusage (old - use with care)


Typical Stefano - only does half the job ;-)

B Rgds
John
« Last Edit: December 10, 2014, 12:33:55 PM by ReetP »
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Stefano

  • *
  • 10,839
  • +2/-0
Re: Mailbox size contrib?
« Reply #5 on: December 10, 2014, 12:35:32 PM »
I disagree with you..
if you use -h switch, you can have size in different measure unit:

Code: [Select]
[root@server ~]# du -h -s /home/e-smith/files/users/*/Maildir | sort -n -r
499M    /home/e-smith/files/users/archivio/Maildir
84K     /home/e-smith/files/users/michele/Maildir
68K     /home/e-smith/files/users/chiara/Maildir
32K     /home/e-smith/files/users/spam/Maildir
32K     /home/e-smith/files/users/riunioni/Maildir
32K     /home/e-smith/files/users/notspam/Maildir
32K     /home/e-smith/files/users/laura/Maildir
32K     /home/e-smith/files/users/katia/Maildir
7.7G    /home/e-smith/files/users/tania/Maildir
6.1G    /home/e-smith/files/users/roberto/Maildir
2.9G    /home/e-smith/files/users/gianni/Maildir
1.2M    /home/e-smith/files/users/assistenza/Maildir

as you can (easily, considering your age) see, you have no order.. :-P

Offline ReetP

  • *
  • 3,740
  • +5/-0
Re: Mailbox size contrib?
« Reply #6 on: December 10, 2014, 01:01:40 PM »
Hence I did the quick edit to say :

Quote
"(ha - quick edit to point out that this doesn't appear to sort correctly. Bug in DU with Gb ?)"

Yes, my age excuses me from many things :-)
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline ReetP

  • *
  • 3,740
  • +5/-0
Re: Mailbox size contrib?
« Reply #7 on: December 10, 2014, 01:25:04 PM »
But this works (a bit of Googling Stefano  :-P :-P :-P )

Code: [Select]
du -s /home/e-smith/files/users/*/Maildir | sort -rn | cut -f2- | xargs -d "\n" du -sh

5.7G   /home/e-smith/files/users/joe/Maildir
853M   /home/e-smith/files/users/brian/Maildir
455M   /home/e-smith/files/users/mark/Maildir
195M   /home/e-smith/files/users/fred/Maildir
70M   /home/e-smith/files/users/nigel/Maildir
924K   /home/e-smith/files/users/marion/Maildir
264K   /home/e-smith/files/users/nellie/Maildir
136K   /home/e-smith/files/users/josh/Maildir
32K   /home/e-smith/files/users/sonia/Maildir
32K   /home/e-smith/files/users/sam/Maildir
32K   /home/e-smith/files/users/sarah/Maildir
32K   /home/e-smith/files/users/judith/Maildir
32K   /home/e-smith/files/users/emilia/Maildir
32K   /home/e-smith/files/users/caroline/Maildir


Soy Ingles, pero no soy loco.....

 :lol: :lol: :lol:
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Stefano

  • *
  • 10,839
  • +2/-0
Re: Mailbox size contrib?
« Reply #8 on: December 10, 2014, 02:33:11 PM »
Hombre, I didn't search because I use that command often :-)

it simply works out of the box :-P

Offline stephdl

  • *
  • 1,519
  • +0/-0
    • Linux et Geekeries
Re: Mailbox size contrib?
« Reply #9 on: December 10, 2014, 06:44:55 PM »
please install ncdu from epel, it is quite simple and a nice CLI
See http://wiki.contribs.org/Koozali_Foundation
irc : Freenode #sme_server #sme-fr

!!! Please write your knowledge to the Wiki !!!

Offline TerryF

  • grumpy old man
  • *
  • 1,826
  • +6/-0
Re: Mailbox size contrib?
« Reply #10 on: December 10, 2014, 10:27:12 PM »
ReetP and Stefano - hey look mines BIGGER than yours   :shock: :lol:
--
qui scribit bis legit

guest22

Re: Mailbox size contrib?
« Reply #11 on: December 10, 2014, 10:39:57 PM »
LOL!

Offline Stefano

  • *
  • 10,839
  • +2/-0
Re: Mailbox size contrib?
« Reply #12 on: December 10, 2014, 10:40:24 PM »
ROTFL :-D