Re: [exim] Logging more information

Etusivu
Poista viesti
Vastaa
Lähettäjä: Marc Sherman
Päiväys:  
Vastaanottaja: exim-users
Aihe: Re: [exim] Logging more information
Craig Jackson wrote:
>
> I wrote this little script that greps the Exim log for incomplete
> transaction, removes duplicate domains, displays the last 250 with line
> numbers and updates every 15 seconds.
>
> #!/bin/bash
>
> while true
> do
>         grep "incomplete transaction" /var/spool/exim/log/mainlog |
> egrep -o "<.*>" | sed "s/[<>]//g" | nl > incomplete_transaction
>         sort -u -t @ -k 2 incomplete_transaction > file
>         sort -n -k 1 file > incomplete_transaction
>         tail -n 250 incomplete_transaction
>         sleep 15
> done

>
> Hope that might help somebody. If you see an improvement please comment.


Not tested, but you should be able to do all that with a single pipeline
to avoid those temporary files:

while true
do
     grep "incomplete transaction" /var/spool/exim/log/mainlog | \
         egrep -o "<.*>" | sed "s/[<>]//g" | nl | \
         sort -u -t @ -k 2 | \
         sort -n -k 1 | \
         tail -n 250
         sleep 15
done


If that doesn't work, you really should use tempfile to avoid
overwriting things in the current directory accidentally.

- Marc