Qmail Statistics (AWStats)

From SME Server
Revision as of 11:19, 7 June 2008 by Mweinber (talk | contribs) (New page: {{Languages}} === Introduction === Quoted from the AWStats homepage: AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, g...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Introduction

Quoted from the AWStats homepage: AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically. This log analyzer works as a CGI or from command line and shows you all possible information your log contains, in few graphical web pages. It uses a partial information file to be able to process large log files, often and quickly. It can analyze log files from all major server tools like Apache log files (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C log format) and a lot of other web, proxy, wap, streaming servers, mail servers and some ftp servers. Read more...

This Howto describes the Qmail statistics setup.

 

Installation

Download the RPM from the AWstats homepage

wget http://prdownloads.sourceforge.net/awstats/awstats-6.7-1.noarch.rpm

Install the RPM

/usr/bin/yum -y localinstall awstats-6.7-1.noarch.rpm


  Note:
If you have the AWStats contrib installed, use this install command
rpm -ivh --force awstats-6.7-1.noarch.rpm



Setup

Execute the following commands or download the script qmail-awstats-setup.sh and run it.

############################ 
# Data directory 
############################ 

mkdir -p /home/e-smith/awstats


############################ 
# Config file for Qmail 
############################ 

DomainName=`config get DomainName`
DNREG=${DomainName/\./\\.}
mkdir -p /etc/awstats

cat <<HERE1 > /etc/awstats/awstats.mail.conf
LogFile="/usr/local/bin/tai64nlocal < /var/log/qmail/current | perl /usr/local/awstats/tools/maillogconvert.pl standard | /bin/grep -v ' alias-localdelivery-' |"
LogType=M
LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd"
LogSeparator=" "
SiteDomain="$DomainName"
HostAliases="localhost 127.0.0.1 REGEX[$DNREG$]"
DNSLookup=2
DirData="/home/e-smith/awstats"
DirCgi="/cgi-bin"
DirIcons="/icon"
AllowToUpdateStatsFromBrowser=0
AllowFullYearView=2
EnableLockForUpdate=0
DNSStaticCacheFile="dnscache.txt"
DNSLastUpdateCacheFile="dnscachelastupdate.txt"
SkipDNSLookupFor=""
AllowAccessFromWebToAuthenticatedUsersOnly=0
AllowAccessFromWebToFollowingAuthenticatedUsers=""
AllowAccessFromWebToFollowingIPAddresses=""
CreateDirDataIfNotExists=0
BuildHistoryFormat=text
BuildReportFormat=html
SaveDatabaseFilesWithPermissionsForEveryone=0
PurgeLogFile=0
ArchiveLogRecords=0
KeepBackupOfHistoricFiles=0
DefaultFile="index.html"
SkipHosts=""
SkipUserAgents=""
SkipFiles=""
SkipReferrersBlackList=""
OnlyHosts=""
OnlyUserAgents=""
OnlyFiles=""
NotPageList="css js class gif jpg jpeg png bmp ico swf"
ValidHTTPCodes="200 304"
ValidSMTPCodes="1 250"
AuthenticatedUsersNotCaseSensitive=0
URLNotCaseSensitive=0
URLWithAnchor=0
URLQuerySeparators="?;"
URLWithQuery=0
URLWithQueryWithOnlyFollowingParameters=""
URLWithQueryWithoutFollowingParameters=""
URLReferrerWithQuery=0
WarningMessages=1
ErrorMessages=""
DebugMessages=0
NbOfLinesForCorruptedLog=50
WrapperScript=""
DecodeUA=0
MiscTrackerUrl="/js/awstats_misc_tracker.js"
LevelForBrowsersDetection=2         
LevelForOSDetection=2               
LevelForRefererAnalyze=2            
LevelForRobotsDetection=2           
LevelForSearchEnginesDetection=2    
LevelForKeywordsDetection=2         
LevelForFileTypesDetection=2        
LevelForWormsDetection=0            
UseFramesWhenCGI=1
DetailedReportsOnNewWindows=1
Expires=0
MaxRowsInHTMLOutput=1000
Lang="auto"
DirLang="./lang"
ShowMenu=1                 
ShowSummary=HBM
ShowMonthStats=HBM
ShowDaysOfMonthStats=HBM
ShowDaysOfWeekStats=HBM
ShowHoursStats=HBM
ShowDomainsStats=0
ShowHostsStats=HBL
ShowAuthenticatedUsers=0
ShowRobotsStats=0
ShowWormsStats=0
ShowEMailSenders=HBML
ShowEMailReceivers=HBML
ShowSessionsStats=0
ShowPagesStats=0
ShowFileTypesStats=0
ShowFileSizesStats=0       
ShowOSStats=0
ShowBrowsersStats=0
ShowScreenSizeStats=0
ShowOriginStats=0
ShowKeyphrasesStats=0
ShowKeywordsStats=0
ShowMiscStats=0
ShowHTTPErrorsStats=0
ShowSMTPErrorsStats=1
ShowClusterStats=0
AddDataArrayMonthStats=1
AddDataArrayShowDaysOfMonthStats=1
AddDataArrayShowDaysOfWeekStats=1
AddDataArrayShowHoursStats=1
IncludeInternalLinksInOriginSection=0
MaxNbOfDomain = 10
MinHitDomain  = 1
MaxNbOfHostsShown = 10
MinHitHost    = 1
MaxNbOfLoginShown = 10
MinHitLogin   = 1
MaxNbOfRobotShown = 10
MinHitRobot   = 1
MaxNbOfPageShown = 10
MinHitFile    = 1
MaxNbOfOsShown = 10
MinHitOs      = 1
MaxNbOfBrowsersShown = 10
MinHitBrowser = 1
MaxNbOfScreenSizesShown = 5
MinHitScreenSize = 1
MaxNbOfWindowSizesShown = 5
MinHitWindowSize = 1
MaxNbOfRefererShown = 10
MinHitRefer   = 1
MaxNbOfKeyphrasesShown = 10
MinHitKeyphrase = 1
MaxNbOfKeywordsShown = 10
MinHitKeyword = 1
MaxNbOfEMailsShown = 20
MinHitEMail   = 1
FirstDayOfWeek=1
ShowFlagLinks=""
ShowLinksOnUrl=1
UseHTTPSLinkForUrl=""
MaxLengthOfShownURL=64
HTMLHeadSection=""
HTMLEndSection=""
Logo="awstats_logo6.png"
LogoLink="awstats.pl?config=mail"
BarWidth   = 260
BarHeight  = 90
StyleSheet=""
color_Background="FFFFFF"      
color_TableBGTitle="CCCCDD"        
color_TableTitle="000000"      
color_TableBG="CCCCDD"         
color_TableRowTitle="FFFFFF"   
color_TableBGRowTitle="ECECEC" 
color_TableBorder="ECECEC"     
color_text="000000"                
color_textpercent="606060"     
color_titletext="000000"       
color_weekend="EAEAEA"         
color_link="0011BB"                
color_hover="605040"           
color_u="FFAA66"               
color_v="F4F090"               
color_p="4477DD"               
color_h="66DDEE"               
color_k="2EA495"               
color_s="8888DD"               
color_e="CEC2E8"               
color_x="C1B2E2"               
ExtraTrackedRowsLimit=500
HERE1


############################
# Webserver configuration
############################

mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf

cat <<HERE2 > /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/86awstats
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
Alias /icon "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"

<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
allow from all
AuthName "Qmail Statistics"
AuthType Basic
AuthExternal pwauth
require user admin
</Directory>

HERE2

expand-template /etc/httpd/conf/httpd.conf
service httpd-e-smith restart

############################
# Cronjob
############################

mkdir -p /etc/e-smith/templates-custom/etc/crontab
cat <<HERE3 > /etc/e-smith/templates-custom/etc/crontab/awstats
15 */1 * * * root /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mail >/dev/null

HERE3

expand-template /etc/crontab

Run the first update manually

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mail


Usage

Point your browser to https://YOUR_SMESERVER_IP/awstats/awstats.pl?config=mail and login as admin.