Scientific Linux 6
Sponsored Link

メールログ解析 - AWstats2011/03/20

 
メールログ解析ツール AWstats をインストールして、Webブラウザからメール送受信履歴を確認できるようにします。 Webサーバーインストール済みが前提です。
[1] AWstats インストール
[root@mail ~]#
yum --enablerepo=rpmforge -y install awstats
 
# RPMforgeからインストール
[root@mail ~]#
cp /etc/awstats/awstats.model.conf /etc/awstats/awstats.mail.srv.world.conf

[root@mail ~]#
vi /etc/awstats/awstats.mail.srv.world.conf
# 51行目:変更

LogFile="
/usr/bin/maillogconvert.pl standard < /var/log/maillog |
"
# 63行目:変更

LogType=
M
# 122行目:コメントにしてその下に追記

#
LogFormat=1
LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd"
# 153行目:ホスト名指定

SiteDomain="
mail.srv.world
"
# 831行目から:該当箇所を以下のように変更

LevelForBrowsersDetection=
0

LevelForOSDetection=
0

LevelForRefererAnalyze=
0

LevelForRobotsDetection=
0

LevelForSearchEnginesDetection=
0

LevelForKeywordsDetection=
0

LevelForFileTypesDetection=
0

LevelForWormsDetection=0
# 905行目:変更

Lang="
jp
"
# 949行目から:該当箇所を以下のように変更

ShowMonthStats=
UHB

ShowDaysOfMonthStats=
HB

ShowDaysOfWeekStats=
HB

ShowHoursStats=
HB

ShowDomainsStats=
0

ShowHostsStats=
HBL

ShowRobotsStats=
0

ShowEMailSenders=
HBML

ShowEMailReceivers=
HBML

ShowSessionsStats=
0

ShowPagesStats=
0

ShowFileTypesStats=
0

ShowOSStats=
0

ShowBrowsersStats=
0

ShowOriginStats=
0

ShowKeyphrasesStats=
0

ShowKeywordsStats=
0

ShowMiscStats=
0

ShowHTTPErrorsStats=
0

ShowSMTPErrorsStats=
1
[root@mail ~]#
vi /etc/httpd/conf.d/awstats.conf
Alias /awstats/icon/ /var/www/awstats/icon/
# Alias追記

Alias /report /var/www/awstats/

ScriptAlias /awstats/ /var/www/awstats/
<Directory "/var/www/awstats/">
DirectoryIndex awstats.pl
    Options ExecCGI
    order deny,allow
    deny from all
    allow from 127.0.0.1
10.0.0.0/24
# アクセス許可IP追記

</Directory>
[root@mail ~]#
/etc/rc.d/init.d/httpd restart

Stopping httpd:
[  OK  ]

Starting httpd:
[  OK  ]
# レポート出力

[root@mail ~]#
/var/www/awstats/awstats.pl -config=mail.srv.world -update

Create/Update database for config "/etc/awstats/awstats.mail.srv.world.conf" by AWStats version 7.0 (build 1.971)
From data in log file "/usr/bin/maillogconvert.pl standard < /var/log/maillog |"...
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: 9
Found 2 dropped records,
Found 0 comments,
Found 0 blank records,
Found 0 corrupted records,
Found 0 old records,
Found 7 new qualified records.
# 出力したレポートをHTMLにする

[root@mail ~]#
/var/www/awstats/awstats.pl -config=mail.srv.world -output -staticlink > /var/www/awstats/index.html
# cronの内容を変更しておく

[root@mail ~]#
vi /etc/cron.hourly/00awstats
#!/bin/bash
if [ -f /var/log/httpd/access_log ] ; then
# コメント化

#
exec /usr/bin/awstats_updateall.pl now -configdir="/etc/awstats" -awstatsprog="/var/www/awstats/awstats.pl" > /dev/null
# 追記

/var/www/awstats/awstats.pl -config=mail.srv.world -update > /dev/null
/var/www/awstats/awstats.pl -config=mail.srv.world -output -staticlink > /var/www/awstats/index.html

fi
exit 0
[2] 「http://(サーバーのホスト名またはIPアドレス/)/report/」にアクセスすると、 以下のような画面が表示されメールログのサマリーを見ることができます。
関連コンテンツ