This page is part of the EmailServer article. Maillog analysis with AWStatsMaillogs are mighty important when troubleshooting or to check if your server is properly configured for its load. AWStats is a generic log analysis package that offers a nice web interface and can be made to analyse almost any type of logs. It's easy to extend too and quite simple to install. I don;t recommend using the RPM from the AWStat website has it has been packaged differently for Fedora and if you use automatic update, your config will change. Just use # yum install awstats # echo alias awstats_updateall.pl=\ "'awstats_updateall.pl -awstatsprog=/var/www/awstats/awstats.pl'" \ >> ~/.bashrc # cd /etc/awstats/ # cp awstats.model.conf awstats.mail.conf The second line creates an alias for the Then edit the LogFile="perl /usr/bin/maillogconvert.pl standard < /var/log/maillog |" LogType=M LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd" SiteDomain="mail.example.com" 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 Now make AWStats update its database regularly from a cron job ( 00 */2 * * * /var/www/awstats/awstats.pl -update -config=mail 00 */3 * * * /var/www/awstats/awstats.pl -update -config=localhost.localdomain Then we can construct the database right now so we can access it for the remaining of our configuration: # awstats_updateall.pl now If there are errors, double-check that you entered all the correct options in the configuration file above. If the script says it can't find AWStats Integration in ApacheSo now we have AWStats installed and updating its database regularly but what we still need is to display the stats in a convenient way. The default installation should have added the following lines to your Alias /awstats/icon/ /var/www/awstats/icon/ ScriptAlias /awstats/ /var/www/awstats/ <Directory /var/www/awstats/> DirectoryIndex awstats.pl Options ExecCGI Order deny,allow Deny from all Allow from 127.0.0.1 192.168.0.0/255.255.255.0 212.87.250.3 </Directory> Now, to access AWStats, you need to point your web browser to
Our solution, amongst many possible, was to add a subdomain NameVirtualHost *:80 <Virtualhost *:80> ServerName mailstats.faiveley-fareast.com DocumentRoot "/var/www/awstats" Alias /awstats/icon/ /var/www/awstats/icon/ ScriptAlias /awstats/ /var/www/awstats/ <Directory /var/www/awstats> DirectoryIndex awstats.pl Options ExecCGI order deny,allow deny from all Allow from 127.0.0.1 192.168.0.0/255.255.255.0 212.87.250.3 </Directory> RewriteEngine on RewriteLog "/var/log/httpd/rewrite_log" RewriteLogLevel 4 RewriteCond %{REQUEST_URI} ^/mail/?$|^/?$ [NC] RewriteCond %{HTTP_HOST} ^(mailstats\..*) [NC] RewriteRule (^.*$) http://%1/awstats/awstats.pl?config=mail RewriteCond %{REQUEST_URI} ^/web/?$ [NC] RewriteCond %{HTTP_HOST} ^(mailstats\..*) [NC] RewriteRule (^.*$) http://%1/awstats/awstats.pl?config=localhost.localdomain RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(mail\..*)$ [NC] RewriteRule (^.*$) https://%1 [L,R] RewriteCond %{HTTP_HOST} ^webmail\.(.*)$ [NC] RewriteRule (^.*$) https://mail.%1 [L,R] </Virtualhost> Requests to the web server wil be transformed as such :
Now, providing we created the mailstats sub-domain, we can access both our mail and web statistics without having to remember those long URLs. Extending AWStatsAWStats by default will provide quite a bit of useful information, but it will also ignore some that it won't understand, like how much spam or viruses were found. How to integrate this information into the stats collected by AWStats will be developped in the near future. Resources
< TroubleShooting | EmailServer Comments RulfoMonday 05 June 2006, at 02:22 GMT+8 [X] Great article, i hope advanced articule could be released soon. Bye |