On Wed, 24 Feb 1999, Van Liedekerke Franky wrote:

> Hi,
> 
> is there a tool available to give a summary of what's in the queue?
> Something like:
> x mails queued for first.domain
> xx mails queued for second.domain
> yy mails deferred for third.domain
> 
> If not, I'll write one myself (using perl of course)
> 
> Franky
> 

Just wrote one for a client. It's called whereto and it lists local
and remote domains and the number of bytes still to be sent. It parses
the output of qmail-qread and output looks like this:

    Local Domains:  0       Local Recipients:       0
    Remote Domains: 17      Remote Recipients:      29
    porterhouse.merrion.nua.net:    1 recips        35532 bytes
    mgw.com.au:     1 recips        2528 bytes
    flash.theglobe.com:     1 recips        7692 bytes
    sal.emailmedia.com:     1 recips        675 bytes
    citysearc.com:  1 recips        3451 bytes
    hotail.com:     1 recips        1944 bytes
    aljan.com.au:   1 recips        2588869 bytes
    smtp.emailserv.com:     1 recips        4273 bytes
    freesex.net:    1 recips        10202 bytes
    koha.net:       1 recips        1749 bytes
    cavalier.com.au:        1 recips        1119 bytes
    ruralink.com.au:        1 recips        7925 bytes
    consult.com.au: 1 recips        2192 bytes
    mega.com.au:    1 recips        554 bytes
    ctbiz.canberratimes.com.au:     1 recips        4252 bytes
    klever.net.au:  2 recips        146917 bytes
    corona.dailysex.net:    12 recips       81127 bytes

Code follwas at end.

Regards
Peter
----------
Peter Samuel                                [EMAIL PROTECTED]
Technical Consultant                        or at present:
Uniq Professional Services,                 [EMAIL PROTECTED]
a division of X-Direct Pty Ltd
Phone: +61 2 9206 3410                      Fax: +61 2 9281 1301

"If you kill all your unhappy customers, you'll only have happy ones left"

###########################################################################
#!/usr/local/bin/perl -w
 
# Where is mail going?
 
use strict;
 
my($locals) = 0;
my($remotes) = 0;
my($bytes) = 0;
my(%remote);
my(%local);
my(%remotebytes);
my(%localbytes);
 
open(QREAD, "/var/qmail/bin/qmail-qread |");
 
while(<QREAD>)
{
    my(@d);
    my(@f);
 
    chomp;
    @f = split(' ');
 
    if (/\sGMT\s/)
    {
        $bytes = $f[6];
    }
 
    if ($f[0] eq "remote")
    {
        @d = split(/\@/, $f[1]);
        $d[1] = lc($d[1]);
        ++$remote{$d[1]};
        ++$remotes;
        $remotebytes{$d[1]} += $bytes;
    }
 
    if ($f[0] eq "local")
    {
        @d = split(/\@/, $f[1]);
        $d[1] = lc($d[1]);
        ++$local{$d[1]};
        ++$locals;
        $localbytes{$d[1]} += $bytes;
    }
}
 
print "Local Domains:\t", scalar keys %local;
print "\tLocal Recipients:\t$locals\n";
 
foreach (sort lnumerically keys %local)
{
    print "$_:\t$local{$_} recips\t$localbytes{$_} bytes\n";
}
 
print "Remote Domains:\t", scalar keys %remote;
print "\tRemote Recipients:\t$remotes\n";
 
foreach (sort rnumerically keys %remote)
{
    print "$_:\t$remote{$_} recips\t$remotebytes{$_} bytes\n";
}
 
sub lnumerically
{
    $local{$a} <=> $local{$b};
}
sub rnumerically
{
    $remote{$a} <=> $remote{$b};
}

Reply via email to