License

Copyright (C) 2008-2018 Oliver Bohlen.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.

A copy of the license is included in the section entitled "GNU Free Documentation License".

Introduction

This documentation comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.

Howto: Statistics for Gentoo Linux

Here is how I create statistics about my web accesses and my mailtraffic. For this I use AWstats.

If you want to use this solution you need the following howto(s) finished:

Required software

The required software has to be installed with the following command(s):
emerge net-www/awstats

Changes in /etc/awstats/awstats.gabosh.net.conf

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /etc/awstats/awstats.gabosh.net.conf

Changed on 18.02.09
Issued by olli
Beginning line 1

This is the AWstats-configuration for my gabosh.net Apache-vHost

LogFile="/var/log/apache2/access_log"
LogType=W
LogFormat = "%virtualname %host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot"
LogSeparator=" "
SiteDomain="example.com"
HostAliases="example.com smtp.example.com pop.example.com pop3.example.com mail.example.com silent-gabosh.example.com silent.example.com gabosh.example.com imap.example.com ns1.example.com"
DNSLookup=1
DirData="/var/lib/awstats"
DirCgi="/cgi-bin"
DirIcons="/intern/awstats/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="194.127.8.17 194.127.8.18 194.127.8.19 194.127.8.20 172.23.0.50 my.lan.ip.addr 127.0.0.1"
SkipUserAgents=""
SkipFiles=""
SkipReferrersBlackList=""
OnlyHosts=""
OnlyUserAgents=""
OnlyUsers=""
OnlyFiles=""
NotPageList="css js class gif jpg jpeg png bmp ico rss xml swf"
ValidHTTPCodes="200 304"
ValidSMTPCodes="1 250"
AuthenticatedUsersNotCaseSensitive=0
URLNotCaseSensitive=0
URLWithAnchor=0
URLWithQuery=0
URLWithQueryWithOnlyFollowingParameters=""
URLWithQueryWithoutFollowingParameters=""
URLReferrerWithQuery=0
WarningMessages=1
ErrorMessages=""
DebugMessages=0
NbOfLinesForCorruptedLog=50
WrapperScript=""
DecodeUA=0
MiscTrackerUrl="/js/awstats_misc_tracker.js"
UseFramesWhenCGI=1
DetailedReportsOnNewWindows=1
Expires=0
MaxRowsInHTMLOutput=1000
Lang="auto"
DirLang="./lang"
ShowMenu=1					
ShowSummary=UVPHB
ShowMonthStats=UVPHB
ShowDaysOfMonthStats=VPHB
ShowDaysOfWeekStats=PHB
ShowHoursStats=PHB
ShowDomainsStats=PHB
ShowHostsStats=PHBL
ShowAuthenticatedUsers=0
ShowRobotsStats=HBL
ShowWormsStats=0
ShowEMailSenders=0
ShowEMailReceivers=0
ShowSessionsStats=1
ShowPagesStats=PBEX
ShowFileTypesStats=HB
ShowFileSizesStats=0		
ShowOSStats=1
ShowBrowsersStats=1
ShowScreenSizeStats=0
ShowOriginStats=PH
ShowKeyphrasesStats=1
ShowKeywordsStats=1
ShowMiscStats=a
ShowHTTPErrorsStats=1
ShowSMTPErrorsStats=0
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="http://awstats.sourceforge.net"
BarWidth   = 260
BarHeight  = 90
StyleSheet=""
ExtraTrackedRowsLimit=500

Changes in /etc/awstats/awstats.mailserver.conf

File permissions:
Owner: root
Group: root
Permissions: -rw-r--r--

Click here for a download of the complete file: /etc/awstats/awstats.mailserver.conf

Changed on 18.02.09
Issued by olli
Beginning line 1

This is the AWstats-configuration for my Mailserver

SiteDomain="silent-gabosh.example.com"
HostAliases="localhost 127.0.0.1 example.com"
LogFile="/usr/bin/awstats_maillogconvert.pl standard < /var/log/maillog.log |" 
LogType=M
LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd"
DirIcons="/intern/awstats/icon"
DirData="/var/lib/awstats"
DNSLookup=1
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 

Changes in /etc/cron.daily/logrotate

File permissions:
Owner: root
Group: root
Permissions: -rwx------

Click here for a download of the complete file: /etc/cron.daily/logrotate

Changed on 03.02.09
Issued by olli
Beginning line 3

Crate statistics before logrotate

/usr/local/bin/awstats

Changes in /usr/local/bin/awstats

File permissions:
Owner: root
Group: root
Permissions: -rwxr-x---

Click here for a download of the complete file: /usr/local/bin/awstats

Changed on 03.02.09
Issued by olli
Beginning line 2

Create statistics every day and write them into the webserver path

# Directory for static statistics
#!/bin/bash

WEBDIR=/var/www/www.example.com/htdocs/intern/awstats
MONTH=$(date +%B-%Y)

# Create Mailserverstatistics
WPATH=$WEBDIR/mailserver/$MONTH
mkdir -p $WPATH
/usr/bin/awstats_buildstaticpages.pl -config=mailserver -update -dir=$WPATH >/dev/null
ln -f $WPATH/awstats.mailserver.html $WPATH/index.html

DOMS=`ls -1 /etc/apache2/vhosts.d/vhosts/ | perl -pe 's/\.vhost$//; s/\.sslvhost$//;' | sort -u`
DOMS="$DOMS `getent group vpn | cut -d: -f4 | perl -pe 's/,/.example.com /g; s/$/.example.com/g;'`"

for DOM in $DOMS
do
 echo "
LogFile=\"/var/log/apache2/access_log\"
LogType=W
LogFormat = \"%virtualname %host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot\"
LogSeparator=\" \"
SiteDomain=\"$DOM\"
DNSLookup=1
DirData=\"/var/lib/awstats\"
DirCgi=\"/cgi-bin\"
DirIcons=\"/intern/awstats/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=\"194.127.8.17 194.127.8.18 194.127.8.19 194.127.8.20 172.23.0.50 my.lan.ip.addr 127.0.0.1\"
SkipUserAgents=\"\"
SkipFiles=\"\"
SkipReferrersBlackList=\"\"
OnlyHosts=\"\"
OnlyUserAgents=\"\"
OnlyUsers=\"\"
OnlyFiles=\"\"
NotPageList=\"css js class gif jpg jpeg png bmp ico rss xml swf\"
ValidHTTPCodes=\"200 304\"
ValidSMTPCodes=\"1 250\"
AuthenticatedUsersNotCaseSensitive=0
URLNotCaseSensitive=0
URLWithAnchor=0
URLWithQuery=0
URLWithQueryWithOnlyFollowingParameters=\"\"
URLWithQueryWithoutFollowingParameters=\"\"
URLReferrerWithQuery=0
WarningMessages=1
ErrorMessages=\"\"
DebugMessages=0
NbOfLinesForCorruptedLog=50
WrapperScript=\"\"
DecodeUA=0
MiscTrackerUrl=\"/js/awstats_misc_tracker.js\"
UseFramesWhenCGI=1
DetailedReportsOnNewWindows=1
Expires=0
MaxRowsInHTMLOutput=1000
Lang=\"auto\"
DirLang=\"./lang\"
ShowMenu=1
ShowSummary=UVPHB
ShowMonthStats=UVPHB
ShowDaysOfMonthStats=VPHB
ShowDaysOfWeekStats=PHB
ShowHoursStats=PHB
ShowDomainsStats=PHB
ShowHostsStats=PHBL
ShowAuthenticatedUsers=0
ShowRobotsStats=HBL
ShowWormsStats=0
ShowEMailSenders=0
ShowEMailReceivers=0
ShowSessionsStats=1
ShowPagesStats=PBEX
ShowFileTypesStats=HB
ShowFileSizesStats=0
ShowOSStats=1
ShowBrowsersStats=1
ShowScreenSizeStats=0
ShowOriginStats=PH
ShowKeyphrasesStats=1
ShowKeywordsStats=1
ShowMiscStats=a
ShowHTTPErrorsStats=1
ShowSMTPErrorsStats=0
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=\"http://awstats.sourceforge.net\"
BarWidth   = 260
BarHeight  = 90
StyleSheet=\"\"
ExtraTrackedRowsLimit=500
" >/etc/awstats/awstats.$DOM.conf
 WPATH=$WEBDIR/$DOM/$MONTH
 mkdir -p $WPATH
 /usr/bin/awstats_buildstaticpages.pl -config=$DOM -update -dir=$WPATH >/dev/null
 ln -f $WPATH/awstats.$DOM.html $WPATH/index.html
done

Please send a feedback to: doc<at>gabosh.net

Howto listing
File Index

Here you can find the official Gentoo Linux Forums where you can find a lot of answers.

Here a link to the official Gentoo Linux Homepage.

Edit Howto

About / Impressum

Click here for About / Impressum

Wishlist

If you want to support my work you can find my Amazon whishlist here