mkogg.py: Fix 'self.get_mp4_metadata(self, source)'
[blog.git] / posts / AWStats.mdwn
1 [AWStats][] is a log analyzer that gives you nice summaries about
2 who's accessing your web server, when they're accessing it, how much
3 bandwidth they're using, etc.  Here's a quick run through installing
4 and using AWStats on [[Gentoo]].
5
6 Install AWStats:
7
8     # emerge -av awstats
9
10 Optionally, copy the log files from a remote server:
11
12     $ rsync -avz example.net:/var/log/apache2/ example-logs/
13
14 Configure AWStats by adjusting the model configuration distributed
15 with AWStats.
16
17     $ cp /etc/awstats/awstats.model.conf awstats.example.conf
18     $ emacs awstats.example.conf
19
20 Here's an example config with the options I use:
21
22     # AWSTATS CONFIGURE FILE 7.0
23     Include "awstats.user.conf.common"
24     LogFile="example-logs/access_log"
25     LogType=W
26     LogFormat=1
27     LogSeparator=" "
28     SiteDomain="www.example.net"
29     HostAliases="localhost 127.0.0.1 REGEX[example\.net$]"
30     DNSLookup=1
31     DirData="data"
32     CreateDirDataIfNotExists=1
33     DirIcons="/usr/share/awstats/wwwroot/icon"
34     BuildHistoryFormat=text
35     LoadPlugin="decodeutfkeys"
36     LoadPlugin="ipv6"
37     LoadPlugin="hashfiles"
38
39 Because `awstats.pl` can be invoked interactively through your browser
40 (depending on how you have it installed), it has a fairly restricted
41 path.  In order to run awstats on files in a random directory
42 (e.g. for processing your server's logs on another host) you should
43 use the `-configdir` option.  Here's an example of parsing the all the
44 archived logs (my logs are archived as `access_log-YYYYMMDD.gz`):
45
46     $ for log in example-logs/access_log-*.gz; do awstats.pl -configdir="${PWD}" -config example -LogFile="gzip -cd ${log} |"; done
47
48 I also analyze logs from another host, whose logs are archived weekly
49 as `access_log.2.gz`, `access_log.3.gz`, etc.  To parse the last year
50 of those archived logs, use something like:
51
52     $ for i in $(seq 52 -1 2); do awstats.pl -configdir="${PWD}" -config=example -LogFile="gzip -cd example-logs/access_log.${i}.gz |"; done
53
54 After working through the archived logs, you can process the current
55 log file:
56
57     $ awstats.pl -configdir="${PWD}" -config=example
58
59 Once all the logs have been processed, run
60
61     $ awstats.pl -configdir="${PWD}" -config=example -update
62
63 To generate the report, run
64
65     $ awstats_buildstaticpages.pl -configdir="${PWD}" -config=example -dir=html
66
67 [AWStats]: http://www.awstats.org/
68
69 [[!tag tags/tools]]
70 [[!tag tags/web]]