Webサーバアクセスログ解析ツール

analogの設定メモ
snmpとmrtg

Jul 29 2009

Debian では apache2 サーバのアクセスログは /var/apache2/access.logです。
これをグラフ化してブラウザから見えるようにするツール analog の設定メモです。


1 インストール


# apt-get install analog

たったのこれだけです。


2 設定

analogの設定ファイル/etc/analog.cfgに入力ファイルとしてapacheのログファイル /var/apache2/access.log
を指定します。また出力ファイルとしてここでは /home/hoge/public_html/analog/report.html
を指定しました。

# はコメントになります。下の赤いところを修正または確認します。

/etc/analog.cfg
# Configuration file for analog 6.0
# See http://www.analog.cx/
#
# Here are a couple of configuration commands to get you started. Add any more
# you like from the Readme.
#
# Lines starting with # are comments.
#
# There is a much more extensive configuration file in examples/big.cfg
#
# If you need a LOGFORMAT command (most people don't -- try it without first!),
# it must go here, above the LOGFILE commands.

# This sets analog to process the apache log files. If you use a web server
# other than apache, you will need to tell analog where the web server
# keeps its log files.
#LOGFILE /var/log/apache/access.log
#LOGFILE /var/log/apache/referer.log
#LOGFILE /var/log/apache/agent.log
# apache2 uses this file instead
LOGFILE /var/log/apache2/access.log

# LOGFILE /old/logs/access_log.*
# OUTFILE Report.html
OUTFILE /home/hoge/public_html/analog/report.html
# HOSTNAME "[my organisation]"
#
# You probably don't need to change anything below this until you are
# experienced.
#
# ERRFILE errors.txt
# REQINCLUDE pages
REQLINKINCLUDE pages
REFLINKINCLUDE *
REDIRREFLINKINCLUDE *
FAILREFLINKINCLUDE *
SUBBROW */*
SUBTYPE *.gz,*.Z
# OSCHARTEXPAND Windows
# Add whichever of these types of pages you have on your server, or others.
# PAGEINCLUDE *.shtml
# PAGEINCLUDE *.asp
# PAGEINCLUDE *.jsp
# PAGEINCLUDE *.cfm
# PAGEINCLUDE *.pl
# PAGEINCLUDE *.php
# More SEARCHENGINE commands can be found at
#   http://www.analog.cx/helpers/#conffiles
SEARCHENGINE http://*google.*/* q,as_q,as_epq,as_oq
SEARCHENGINE http://*altavista.*/* q
SEARCHENGINE http://*yahoo.*/* p
SEARCHENGINE http://*lycos.*/* query,wfq
SEARCHENGINE http://*aol.*/* query
SEARCHENGINE http://*excite.*/* search
SEARCHENGINE http://*go2net.*/* general
SEARCHENGINE http://*metacrawler.*/* general
SEARCHENGINE http://*msn.*/* q,MT
SEARCHENGINE http://*netscape.*/* search
SEARCHENGINE http://*looksmart.*/* key
SEARCHENGINE http://*webcrawler.*/* qkw,search,searchText
SEARCHENGINE http://*overture.*/* Keywords
SEARCHENGINE http://*teoma.*/* q
SEARCHENGINE http://*infospace.*/* qkw
SEARCHENGINE http://*alltheweb.*/* q
SEARCHENGINE http://*dogpile.*/* q
SEARCHENGINE http://*ask.*/* q,ask
SEARCHENGINE http://*alltheweb.*/* query
SEARCHENGINE http://*northernlight.*/* qr
SEARCHENGINE http://*nlsearch.*/* qr
SEARCHENGINE http://*dmoz.*/* search
SEARCHENGINE http://*/netfind* query
SEARCHENGINE http://*/pursuit query
ROBOTINCLUDE REGEXPI:robot
ROBOTINCLUDE REGEXPI:spider
ROBOTINCLUDE REGEXPI:crawler
ROBOTINCLUDE Googlebot*
ROBOTINCLUDE msnbot*
ROBOTINCLUDE Infoseek*
ROBOTINCLUDE Scooter*
ROBOTINCLUDE *Slurp*
ROBOTINCLUDE *Validator*
ROBOTINCLUDE Ultraseek*
TYPEALIAS .html    ".html [Hypertext Markup Language]"
TYPEALIAS .htm     ".htm  [Hypertext Markup Language]"
TYPEALIAS .shtml   ".shtml [Server-parsed HTML]"
TYPEALIAS .ps      ".ps   [PostScript]"
TYPEALIAS .gz      ".gz   [Gzip compressed files]"
TYPEALIAS .tar.gz  ".tar.gz [Compressed archives]"
TYPEALIAS .jpg     ".jpg  [JPEG graphics]"
TYPEALIAS .jpeg    ".jpeg [JPEG graphics]"
TYPEALIAS .gif     ".gif  [GIF graphics]"
TYPEALIAS .png     ".png  [PNG graphics]"
TYPEALIAS .txt     ".txt  [Plain text]"
TYPEALIAS .cgi     ".cgi  [CGI scripts]"
TYPEALIAS .pl      ".pl   [Perl scripts]"
TYPEALIAS .css     ".css  [Cascading Style Sheets]"
TYPEALIAS .class   ".class [Java class files]"
TYPEALIAS .pdf     ".pdf  [Adobe Portable Document Format]"
TYPEALIAS .zip     ".zip  [Zip archives]"
TYPEALIAS .hqx     ".hqx  [Macintosh BinHex files]"
TYPEALIAS .exe     ".exe  [Executables]"
TYPEALIAS .wav     ".wav  [WAV sound files]"
TYPEALIAS .avi     ".avi  [AVI movies]"
TYPEALIAS .arc     ".arc  [Compressed archives]"
TYPEALIAS .mid     ".mid  [MIDI sound files]"
TYPEALIAS .mp3     ".mp3  [MP3 sound files]"
TYPEALIAS .ogg     ".ogg  [OGG sound files]"
TYPEALIAS .doc     ".doc  [Microsoft Word document]"
TYPEALIAS .rtf     ".rtf  [Rich Text Format]"
TYPEALIAS .mov     ".mov  [Quick Time movie]"
TYPEALIAS .mpg     ".mpg  [MPEG movie]"
TYPEALIAS .mpeg    ".mpeg [MPEG movie]"
TYPEALIAS .asp     ".asp  [Active Server Pages]"
TYPEALIAS .jsp     ".jsp  [Java Server Pages]"
TYPEALIAS .cfm     ".cfm  [Cold Fusion]"
TYPEALIAS .php     ".php  [PHP]"
TYPEALIAS .js      ".js   [JavaScript code]"


それから/home/hoge/public_html/report.htmlの棒グラフに使う材料をこのディレクトリにコピーしておきます。


$ cp /usr/share/analog/images/*.png .
$ cp /usr/share/analog/images/*.gif .

3 使い方
ルートで
# analog

上のようにコマンドを1回動作させればanalog.cfg内に指定した出力先
(ここでは /var/www/analog/)にreport.html ファイルが出力されます。
これをブラウザで見るだけです。実際のurlアドレスは
http://karappi.minidns.net/analog/report.html

です。

あとはcrontab命令で定期的にanalog を実行すればOKです。

# crontab -e
毎日23:50にanalogコマンドを実行する設定
# m h  dom mon dow   command
50 23 * * * /usr/bin/analog


目次