----- Original Message -----
From: "Justin R. Miller" <[EMAIL PROTECTED]>
To: "vpopmail list" <[EMAIL PROTECTED]>
Sent: Wednesday, October 09, 2002 5:43 PM
Subject: Re: [vchkpw] Check Space Usage

> Is there an efficient way to do this if you _don't_ use quotas, ideally
> something other than 'du'?

You can open a pipe to 'ls' since the mail sizes are in the name. Quite
easy, though it's up for debate if this is more efficient than du.

This also doesn't take into account other files in the Maildir that aren't
actually messages, but depending on your point of view, these files
shouldn't be included in the user quota anyways.

Snippet of ls pipe (haven't converted to native opendir and readdir yet,
which is probably a bit faster since it saves a process being launched):

            open (IN, "ls $homeDir/Maildir/$dir |");
            while ($line = <IN>){
               chomp $line;
               ($garbage,$size) = split(',', $line);
               ($garbage,$size) = split('=', $line);

               # $filename = "$homeDir/Maildir/$dir" . $line;
               $MailBoxSize += $size;

Even better would be native opendir() and readdir(), since it saves a
process being launched. At this point, savings are likely to be minimal,
even with thousands of mailboxes.

Depending on how you do backups and what your needs are for calculating used
space, you might be better analyzing last night's backups instead of live
data. We copy the main data store every night to a seperate disk as part of
our backup, so running analysis on this disk would be quite a bit faster
than on the live store. If you don't need "live" quota management, this
might be acceptable.


Reply via email to