Re: [exim] Parsing Spool Files

Page principale
Supprimer ce message
Répondre à ce message
Auteur: John Jetmore
Date:  
À: Matt
CC: exim-users
Sujet: Re: [exim] Parsing Spool Files
On Tue, Nov 13, 2012 at 10:12 AM, Matt <matt.mailinglists@???> wrote:
>> Looking at format of spool files.
>>
>> Format of spool files:
>> http://www.exim.org/exim-html-3.20/doc/html/spec_56.html
>>
>> What I would like to do is parse all the Header files and count the
>> number of recipients that are in the Queue for every "host_address"
>> and add them up. I would like to do this every 15 minutes and defer
>> messages from any IP that has over 50 recipients in the queue due to
>> delivery issues. Not wanting to reinvent the wheel but is there any
>> script out there already that does this?
>>
>> Perhaps there is an easier way to do this? I want a count of how many
>> undelivered recipients in the queue for each "host_address" that has
>> messages in the queue.
>
> Was really wandering if there was an easier way then parsing files.
> Perhaps an exim queue command.
>
> http://serversitters.com/exim-mail-queue-commands.html
>
> Just not finding anything that lists host_address. Am I missing something?


exipick --show-vars sender_host_address

(sender_host_address is the expansion variable that -host_address gets
stuffed into after processing)

You can also get each message's recipient count the same way:

exipick --show-vars sender_host_address,recipients_count

There's no single flag in exipick to get exactly what you want though.
How about:

exipick --show-vars sender_host_address,recipients_count | perl -naF\'
-e '$l = $F[1] if $F[0] =~ "sender_host_address"; $c{$l} += $F[1] if
$F[0] =~ "recipients_count"; END { map { print "$_\t$c{$_}\n"; } (keys
%c); }'

--
jetmore@lappy:~$ sudo exipick
12m   493 1TYIGE-00025U-JS <jetmore@???>
          jetmore@???


 0m   493 1TYIRs-00027i-0e <jetmore@???>
          jetmore@???


 0m   493 1TYIRs-00027k-N6 <jetmore@???>
          jetmore@???


 0m   513 1TYISH-00027r-Ky <jetmore@???>
          jetmore@???
          jetmore@???


jetmore@lappy:~$ sudo exipick --show-vars
sender_host_address,recipients_count | perl -naF\' -e '$l = $F[1] if
$F[0] =~ "sender_host_address"; $c{$l} += $F[1] if $F[0] =~
"recipients_count"; END { map { print "$_\t$c{$_}\n"; } (keys %c); }'
127.0.0.1       2
192.168.0.4     3


--John