awstats.model.conf を自分好みの雛形に書き直した。
awstat.patch を適用する。
$ cd /etc/awstats/
$ patch -b awstats.model.conf < awstats.patch
以下patch
$ cat awstats.patch --- awstats.model.conf_org 2012-12-06 14:51:21.000000000 +0900 +++ awstats.model.conf 2012-12-06 15:48:06.000000000 +0900 @@ -48,8 +48,8 @@ # If there are several log files from load balancing servers : # Example: "/pathtotools/logresolvemerge.pl *.log |" # -LogFile="/var/log/httpd/mylog.log" - +#LogFile="/var/log/httpd/mylog.log" +LogFile="/bin/cat /var/log/httpd/example_log.1 /var/log/httpd/example._log |" # Enter the log file type you want to analyze. # Possible values: @@ -119,7 +119,7 @@ # Example for IIS: # LogFormat = 2 # -LogFormat=1 +LogFormat = 1 # If your log field's separator is not a space, you can change this parameter. @@ -150,7 +150,7 @@ # Example: "ftp.domain.com" # Example: "domain.com" # -SiteDomain="" +SiteDomain="www.example.jp" # Enter here all other possible domain names, addresses or virtual host @@ -165,7 +165,8 @@ # Note: You can also use @/mypath/myfile if list of aliases are in a file. # Example: "www.myserver.com localhost 127.0.0.1 REGEX[mydomain\.(net|org)$]" # -HostAliases="localhost 127.0.0.1 REGEX[myserver\.com$]" +#HostAliases="localhost 127.0.0.1 REGEX[myserver\.com$]" +HostAliases="localhost 127.0.0.1 REGEX[example\.jp$]" # If you want to have hosts reported by name instead of ip address, AWStats @@ -185,7 +186,8 @@ # 2 - DNS Lookup is made only from static DNS cache file (if it exists) # Default: 2 # -DNSLookup=2 +#DNSLookup=2 +DNSLookup=1 # When AWStats updates its statistics, it stores results of its analysis in @@ -200,7 +202,8 @@ # Example: "C:/awstats_data_dir" # Default: "." (means same directory as awstats.pl) # -DirData="." +#DirData="." +DirData="/usr/local/awstats/var/lib/awstats" # Relative or absolute web URL of your awstats cgi-bin directory. @@ -219,7 +222,8 @@ # Example: "../icon" # Default: "/icon" (means you must copy icon directories in "/mywwwroot/icon") # -DirIcons="/icon" +#DirIcons="/icon" +DirIcons="/awstatsicons" # When this parameter is set to 1, AWStats adds a button on report page to @@ -327,6 +331,7 @@ # Default: 0 # AllowAccessFromWebToAuthenticatedUsersOnly=0 +#AllowAccessFromWebToAuthenticatedUsersOnly=1 # This parameter gives the list of all authorized authenticated users to view @@ -337,7 +342,7 @@ # Example: "__REMOTE_USER__" # Default: "" # -AllowAccessFromWebToFollowingAuthenticatedUsers="" +AllowAccessFromWebToFollowingAuthenticatedUsers="example_user" # When this parameter is defined to something, the IP address of the user that @@ -463,8 +468,8 @@ # Example: "localhost REGEX[^.*\.localdomain$]" # Default: "" # -SkipHosts="" - +#SkipHosts="" +SkipHosts="127.0.0.1 REGEX[^192\.168\.] localhost REGEX[^.*\.localdomain$]" # Do not include access from clients with a user agent that match following # criteria. If you want to exclude a robot, you should update the robots.pm @@ -476,7 +481,8 @@ # Example: "konqueror REGEX[ua_test_v\d\.\d]" # Default: "" # -SkipUserAgents="" +#SkipUserAgents="" +SkipUserAgents="Nagios" # Use SkipFiles to ignore access to URLs that match one of following entries. @@ -494,8 +500,8 @@ # Example: "/badpage.php /page.php?param=x REGEX[^\/excludedirectory]" # Default: "" # -SkipFiles="" - +#SkipFiles="" +SkipFiles="REGEX[^\/awstats\/] REGEX[^\/admin\/]" # Use SkipReferrersBlackList if you want to exclude records coming from a SPAM # referrer. Parameter must receive a local file name containing rules applied
# mkdir -p /usr/local/awstats/var/lib/awstats
apache の設定
# cp /usr/local/awstats/tools/httpd_conf /etc/httpd/conf.d/awstats.conf
Virttual Hostの設定などがあれば、そっちに書く。
$ cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.example.jp.conf
SiteDomain などを変更する。
解析スクリプトを動かす。
$ perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.example.jp -update
cron 設定
# cat /etc/cron.d/awstat
7 5 * * * root /usr/bin/perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.example.jp -update
閲覧はconfigの引数を付ける。
http://www.example.jp/awstats/awstats.pl?config=www.example.jp