Awstats and maillog

From Secure Computing Wiki
Jump to: navigation, search

PROBLEM:' What do I have to do to use AWStats to analyze my mail log files?

SOLUTION: This tip works with AWStats 5.5 or higher and Postfix, Sendmail, QMail or MDaemon log files.

You must setup AWStats to use a mail log file preprocessor (maillogconvert.pl is provided into AWStats tools directory, but you can use the one of your choice): For this, copy config "awstats.model.conf" file to "awstats.mail.conf". Modify this new config file: For standard Postfix, Sendmail, MDaemon and standard QMail logfiles, set:

LogFile="perl /path/to/maillogconvert.pl standard < /pathtomaillog/maillog |"
If the logfiles are compressed, they can be processed this way
LogFile="gzip -cd /var/log/maillog.0.gz | /path/to/maillogconvert.pl standard |"
And for VAdmin QMail logfiles (multi-host/virtualhost mail servers running vadmin software), set
LogFile="perl /path/to/maillogconvert.pl vadmin < /pathtomaillog/maillog |"
Then, whatever is you mail server, you must also change: 
LogType=M 
LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd" 
LevelForBrowsersDetection=0 
LevelForOSDetection=0 
LevelForRefererAnalyze=0 
LevelForRobotsDetection=0 
LevelForWormsDetection=0 
LevelForSearchEnginesDetection=0 
LevelForFileTypesDetection=0 
ShowMenu=1 
ShowSummary=HB 
ShowMonthStats=HB 
ShowDaysOfMonthStats=HB 
ShowDaysOfWeekStats=HB 
ShowHoursStats=HB 
ShowDomainsStats=0 
ShowHostsStats=HBL 
ShowAuthenticatedUsers=0 
ShowRobotsStats=0 
ShowEMailSenders=HBML 
ShowEMailReceivers=HBML 
ShowSessionsStats=0 
ShowPagesStats=0 
ShowFileTypesStats=0 
ShowFileSizesStats=0 
ShowBrowsersStats=0 
ShowOSStats=0 
ShowOriginStats=0 
ShowKeyphrasesStats=0 
ShowKeywordsStats=0 
ShowMiscStats=0 
ShowHTTPErrorsStats=0 
ShowSMTPErrorsStats=1 
Warning: For MDaemon mail server, you must use the new MDaemon log file that ends with "-Statistics.log".

Now you can use AWStats as usual (run the update process and read statistics).