#contents();
*** インストール [#r71355ab]
- &ref(awstats.pdf,center,マニュアル); を参照してインストールを行う
- yum が Fedra のリポジトリを読み込むように設定し、yum で自動インストールを行った


*** Apache 設定の追加 (/etc/httpd/conf/httpd.conf) [#d1e8e019]
- 自動インストール時に /etc/httpd/conf.d の下に awstats.conf が自動生成されたので、中身を編集した

 [root@spirit ~]# cat /etc/httpd/conf.d/awstats.conf
 Alias /awstats/icon/ /var/www/html/awstats/icon/
 ScriptAlias /awstats/ /var/www/html/awstats/
 
 <Directory /var/www/html/awstats/>
 #       DirectoryIndex awstats.pl
         DirectoryIndex index.html
         Options ExecCGI
         order deny,allow
         deny from all
         allow from All
 #       allow from 127.0.0.1
 
         AddHandler php-script .php
         AddHandler image/gif .gif
         AddHandler image/jpeg .jpeg .jpg
         AddHandler image/png .png
         AddHandler text/html .html .htm
 </Directory>
 
 #Alias /css/ /var/www/html/awstats/css/
 #Alias /js/ /var/www/html/awstats/js/

*** 情報収集用設定ファイル ( /etc/awstats/awstats.postfix.conf )  の編集 [#oa05ce62]
- &ref(awstats.postfix.conf);
-- 解析対象ファイルの指定 (名称、ログの種類 など) ・・・・ &color(red){今回は下記のように sed を使って自動整形されたログファイルを更に加工するように指定した};
-- 解析対象データの指定 (カウントしないホスト名 など)
-- 表示内容の設定 (項目、内容、言語、DNSの逆引きをするか、表示行数など)

 1#LogFile="perl /var/www/html/awstats/tools/maillogconvert.pl standard < /var/log/maillog |"
 2 # muna remover local looped (spam filter loop) mail record from maillog
 3 #
 4 LogFile="/var/www/html/awstats/postfix/formatted_log2"
 5 LogType=M
 6 LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd"
 7
 8 SiteDomain="mail.hmuna.com"
 9 HostAliases="hmuna.com"
 10
 11 #Skiphosts="REGEX[^.*localhost.] REGEX[^.*@(|mail.|localost.)hmuna.com] munakata.hisao@renesas.com munakata@postman.hsdv.com"
 12 #Skiphosts="REGEX[^.*munakata]"
 13 #Skiphosts="localhost"
 14 Skiphosts="munakata@postman.hsdv.com"
 15
 16
 17 DNSLookup=0
 18
 19 DirData="/var/www/html/awstats/postfix"
 20 DirCgi="/var/www/html/awstats"
 21 DirIcons="/var/www/html/awstats/icon"
 22
 23 EnableLockForUpdate=0
 24 AllowAccessFromWebToFollowingIPAddresses=""
 25 AllowToUpdateStatsFromBrowser=0
 26 Lang="jp"
 27
 28 LevelForBrowsersDetection=0
 29 LevelForOSDetection=0
 30 LevelForRefererAnalyze=0
 31 LevelForRobotsDetection=0
 32 LevelForWormsDetection=0
 33 LevelForSearchEnginesDetection=0
 34 LevelForFileTypesDetection=0
 35
 36 ShowMenu=1
 37 ShowSummary=1
 38 ShowMonthStats=0
  ( snip )

*** maillog データのコンバーター (awstats/tools/maillogconvert.pl) [#de924c0c]
- awstats に postfix など各種MTAのログを整形するツールが付属している
- 整形前の postfix のログ

 Dec 11 18:07:33 spirit postfix/anvil[9465]: statistics: max connection count 1 for (smtp:58.69.62.10) at Dec 11 18:02:10
 Dec 11 18:07:33 spirit postfix/anvil[9465]: statistics: max cache size 1 at Dec 11 18:02:10
 Dec 11 18:07:36 spirit postfix/smtpd[9506]: connect from 114.8.221.202.ts.2iij.net[202.221.8.114]
 Dec 11 18:07:36 spirit postfix/smtpd[9506]: setting up TLS connection from 114.8.221.202.ts.2iij.net[202.221.8.114]
 Dec 11 18:07:36 spirit postfix/smtpd[9506]: TLS connection established from 114.8.221.202.ts.2iij.net[202.221.8.114]: TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)
 Dec 11 18:07:36 spirit postfix/smtpd[9506]: F3D3FFD01ED: client=114.8.221.202.ts.2iij.net[202.221.8.114], sasl_method=CRAM-MD5, sasl_username=munakata
 Dec 11 18:07:37 spirit postfix/cleanup[9510]: F3D3FFD01ED: message-id=<457D1FD8.4030504@renesas.com>
 Dec 11 18:07:37 spirit postfix/qmgr[6484]: F3D3FFD01ED: from=<munakata.hisao@renesas.com>, size=34920, nrcpt=1 (queue active)
 Dec 11 18:07:37 spirit postfix/smtpd[9506]: disconnect from 114.8.221.202.ts.2iij.net[202.221.8.114]
 Dec 11 18:07:37 spirit imap-login: Login: munakata [202.221.8.114]
- フィルター(maillogconvert.pl)で整形したログ

 [root@spirit ~]# /var/www/html/awstats/tools/maillogconvert.pl standard | tail /var/log/maillog
 Dec 11 18:07:33 spirit postfix/anvil[9465]: statistics: max connection count 1 for (smtp:58.69.62.10) at Dec 11 18:02:10
 Dec 11 18:07:33 spirit postfix/anvil[9465]: statistics: max cache size 1 at Dec 11 18:02:10
 Dec 11 18:07:36 spirit postfix/smtpd[9506]: connect from 114.8.221.202.ts.2iij.net[202.221.8.114]
 Dec 11 18:07:36 spirit postfix/smtpd[9506]: setting up TLS connection from 114.8.221.202.ts.2iij.net[202.221.8.114]
 Dec 11 18:07:36 spirit postfix/smtpd[9506]: TLS connection established from 114.8.221.202.ts.2iij.net[202.221.8.114]: TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)
 Dec 11 18:07:36 spirit postfix/smtpd[9506]: F3D3FFD01ED: client=114.8.221.202.ts.2iij.net[202.221.8.114], sasl_method=CRAM-MD5, sasl_username=munakata
 Dec 11 18:07:37 spirit postfix/cleanup[9510]: F3D3FFD01ED: message-id=<457D1FD8.4030504@renesas.com>
 Dec 11 18:07:37 spirit postfix/qmgr[6484]: F3D3FFD01ED: from=<munakata.hisao@renesas.com>, size=34920, nrcpt=1 (queue active)
 Dec 11 18:07:37 spirit postfix/smtpd[9506]: disconnect from 114.8.221.202.ts.2iij.net[202.221.8.114]
 Dec 11 18:07:37 spirit imap-login: Login: munakata [202.221.8.114]

*** sed によるメールログ(整形済み)の二次フィルタリング [#zc330fb8]
- SPAM チェック用のサーバー内転送を解析対象から除外する処理
- renesas.com からの munakata.hisao@renesas.com メール転送を除外する

 sed -e '{/localhost localhost/d
          /munakata.hisao@renesas.com/d
 }' /var/www/html/awstats/postfix/formatted_log > /var/www/html/awstats/postfix/formatted_log2

*** cron によるデータの自動修正 [#ae2c084e]

- cron.dayly から /root/script/awstats_postfix.sh を実行させる


- &ref(awstats_postfix.sh); の内容

 [root@spirit ~]# cat /root/script/awstats_postfix.sh
 #!/bin/sh
 
  /var/www/html/awstats/tools/maillogconvert.pl standard < /var/log/maillog > /var/www/html/awstats/postfix/formatted_log
 sed -e '{/localhost localhost/d
          /munakata.hisao@renesas.com/d
 }' /var/www/html/awstats/postfix/formatted_log > /var/www/html/awstats/postfix/formatted_log2
 /var/www/html/awstats/awstats.pl -config=postfix -update
 /var/www/html/awstats/awstats.pl -config=postfix -output -staticlinks | nkf -e > /var/www/html/awstats/index.html

*** データーベースの初期化 [#w0f37473]

 [root@spirit ~]# rm -fR /var/www/html/awstats/postfix/
 [root@spirit ~]# mkdir /var/www/html/awstats//postfix
 [root@spirit ~]# ./script/awstats_postfix.sh
 Update for config "/etc/awstats/awstats.postfix.conf"
 With data in log file "/var/www/html/awstats/postfix/formatted_log2"...
 Phase 1 : First bypass old records, searching new record...
 Searching new records from beginning of log file...
 Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
 Jumped lines in file: 0
 Parsed lines in file: 5486
  Found 0 dropped records,
  Found 49 corrupted records,
  Found 0 old records,
  Found 5437 new qualified records.

*** 参考 URL [#z5f12ad7]
- [[AWStatus 本家:http://awstats.sourceforge.net/]]
- [[AWStats 6.5完全日本語版:http://www.bflets.dyndns.org/Tools/AWStatsJpn.html]]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS