topleft topright

Tranquil Hosting Blog

Archive for November, 2007

Parse exim logs for large attachments

Wednesday, November 14th, 2007

This Python script can be used for parsing exim mail logs to find messages that are over a certain filesize. In this case we were looking for senders of messages over 10MB (10000000 bytes). You can change that in the second to last line of the script.

example usage: cat /var/log/exim_mainlog | grep domain.com | msgsizefilter.py

Here it is:


#!/usr/bin/env python

import sys
for line in sys.stdin.readlines():
if line.find("S=") != -1:
s = int(line.split("S=")[1].split(" ")[0])
d = " ".join( line.split(" ")[0:2])
e = line.split(" <= ")[1].split(" ")[0]
if s > 10000000:
print “%s \t %d \t (%s)” % (d, s, e)

Copyright © 2007, Tranquil Hosting, Inc.
Managed Dedicated Servers | Managed Virtual Private Servers | Raleigh Datacenter Colocation
Raleigh, North Carolina Premium Hosting Provider
Terms of Service