Ubuntu 15.04
Sponsored Link

メールログ解析ツール : AWstats2015/05/25

 
メールログ解析ツール AWstats をインストールして、Webブラウザからメール送受信履歴を確認できるようにします。
[1]
[2] AWstats のインストールと設定です。
root@mail:~#
apt-get -y install awstats
root@mail:~#
cp /etc/awstats/awstats.conf /etc/awstats/awstats.postfix.conf

root@mail:~#
cp /usr/share/doc/awstats/examples/maillogconvert.pl /usr/share/awstats

root@mail:~#
vi /etc/awstats/awstats.postfix.conf
# 51行目:変更

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

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

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

SiteDomain="
mail.srv.world
"
# 223行目:変更

DirIcons="
./icon
"
# 839行目:以下のように変更

LevelForBrowsersDetection=
0

LevelForOSDetection=
0

LevelForRefererAnalyze=
0

LevelForRobotsDetection=
0

LevelForSearchEnginesDetection=
0

LevelForKeywordsDetection=
0

LevelForFileTypesDetection=
0

LevelForWormsDetection=0
# 957行目から:以下のように変更

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:~#
mkdir /var/www/html/awstats

root@mail:~#
ln -s /usr/share/awstats/icon /var/www/html/awstats/icon

root@mail:~#
vi /etc/apache2/sites-available/awstats.conf
# 新規作成

<Directory /var/www/html/awstats>
    Require ip 127.0.0.1 10.0.0.0/24
</Directory>
root@mail:~#
a2ensite awstats

Enabling site awstats.
To activate the new configuration, you need to run:
  service apache2 reload

root@mail:~#
systemctl restart apache2

# レポート出力

root@mail:~#
/usr/lib/cgi-bin/awstats.pl -config=postfix -update

Create/Update database for config "/etc/awstats/awstats.postfix.conf" by AWStats version 7.2 (build 1.992)
From data in log file "/usr/share/awstats/maillogconvert.pl standard < /var/log/mail.log |"...
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)...
Warning: awstats has detected that some hosts names were already resolved in your logfile 
/usr/share/awstats/maillogconvert.pl standard < /var/log/mail.log |.
If DNS lookup was already made by the logger (web server), you should change your setup 
DNSLookup=1 into DNSLookup=0 to increase awstats speed.
Jumped lines in file: 0
Parsed lines in file: 7
 Found 0 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:~#
/usr/lib/cgi-bin/awstats.pl -config=postfix -output -staticlink > /var/www/html/awstats/index.html

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