Grep Patterns for MailScanner Statistics

Denis Beauchemin Denis.Beauchemin at
Tue Nov 28 16:39:35 GMT 2006

Daniel Straka a écrit :
> I've been trying to find a grep pattern to use with the mail log file to
> get an accurate count of:
> 1. Total Incoming Messages: (I'm using sendmail), been using (grep -c
> "daemon=MTA" mail)
> 2. Total Outgoing Messages: been using (grep -c "to=<" mail)
> 3. Messages identified as spam by MailScanner: been using (grep -c
> "actions are delete" mail)
> 4. Total number of messages sent and received: help!
> Does anyone have a list of grep patterns they use and would like to
> share?


You can't use these grep to differentiate between incoming and outgoing 
messages because all messages have a "to=<".  I think you would have to 
look at the IP address of the sender that you can find on the "from=" line:
Nov 28 00:15:15 smtpe3 sendmail[8590]: kAS5F3JI008590: 
from=<..... at .....>, size=0, class=0, nrcpts=0, proto=ESMTP, daemon=MTA, 

Look at the "relay=" for the IP address.  Then decide which ones are 
incoming and outgoing based on that information.

I use Mailscanner-MRTG for this kind of information while others use 
MailWatch.  Look into the wiki for pointers to both.


  °v°   Denis Beauchemin, analyste
 /(_)\  Université de Sherbrooke, S.T.I.
  ^ ^   T: 819.821.8000x62252 F: 819.821.8045

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3595 bytes
Desc: S/MIME Cryptographic Signature
Url :

More information about the MailScanner mailing list