|
|
 |
|
 |
|
|
文章主題: [教學] 用AWSTATS分析www, mail, ftp 記錄檔
發表於: 2004-01-31 14:42
|
|
程式介紹
來自開發者︰“Advanced Web Statistics (AWStats) 是一個免費且強大的Web日誌(Log)文件分析器,它能夠幫助你分析包括使用者,獨特使用者,訪問頁面數,點擊數,刷新時間,作業系統,瀏覽器版本,搜索引擎,關鍵字,錯誤鏈接等等,支援所有的Web伺服器。”
http://awstats.sourceforge.net/
教學轉載
使用AWSTATS分析www, mail, ftp 記錄檔
cna示範網頁
網頁apache2.0分析
http://cna.kyit.edu.tw/cgi-bin/awstats/awstats.pl?config=cna.kyit.edu.tw
檔案伺服器proftp分析
http://cna.kyit.edu.tw/cgi-bin/awstats/awstats.pl?config=ftp
郵件postfix分析
http://cna.kyit.edu.tw/cgi-bin/awstats/awstats.pl?config=mail
使用AWSTATS分析www(apache2.0),mail(postfix),ftp(proftpd)記錄檔
(1)環境及程式
首先先講一下我的安裝環境,我是用mandrake linux 9.1版,安裝套件全選...
來這裡抓最新版的,其實抓6.0,5.9安裝方式都大同小異
http://awstats.sourceforge.net/#DOWNLOAD
我這裡是以6.0 版作範例
# http://awstats.sourceforge.net/files/awstats-6.0.tgz
(2)安裝
# tar zxvf awstats-6.0.tgz
>>解開壓縮檔
# chown root.root awstats-6.0 -R
>>因為解出來uid,gid怪怪的,通通把他改成root,免得看起來不順眼
# mv awstats-6.0/wwwroot/cgi-bin /var/www/cgi-bin/awstats
# mv awstats-6.0/tools /var/www/cgi-bin/awstats/tools
>>將動態的程式搬到 /var/www/cgi-bin/awstats (可執行cgi的目錄)
# mv awstats-6.0/wwwroot /var/www/html/awstats
>>將靜態文件搬到 /var/www/cgi-bin/ (網址根目錄下的位址)
>>這時剩下在 awstats-6.0只有說明文件,就看你的心情處理了 ^^
(3)設定httpd分析前,調整httpd log記錄檔格式
# vi /etc/httpd/conf/commonhttpd.conf
CustomLog logs/access_log combined
>>找到這一行,並將註解去除,其目的為修改apache2.0的設定檔為combined格式,
>>其格式大概長的像這樣
>>62.161.78.75 - - [dd/mmm/yyyy:hh:mm:ss +0000] "GET / HTTP/1.1" 200 1234
>>"http://www.from.com/from.html" "Mozilla/4.0 (compatible; MSIE 5.01;
>>Windows NT 5.0)"
# /etc/rc.d/init.d/httpd restart
>>重新啟動apache
# rm /var/log/httpd/access_log -f
>>刪除舊有的格式檔,免得讀舊格式出問題
(4)設定awstats分析access_log檔
# cd /var/www/cgi-bin/awstats/
>>切換到目錄
# cp awstats.model.conf awstats.cna.kyit.edu.tw.conf
>>拷貝一份設定檔,其中cna.kyit.edu.tw換成你的domain name
# chmod 755 awstats.cna.kyit.edu.tw.conf
>>修改讀寫權限
# mkdir data
>>建立data目錄以供記錄資訊存放
# vi awstats.cna.kyit.edu.tw.conf
LogFile="/var/log/httpd/access_log"
SiteDomain="cna.kyit.edu.tw"
DirData="./data"
DirIcons="/awstats/icon"
>>修改這幾個項目符合成你的需要
(5)分析記錄更新
# ./awstats.pl -config=cna.kyit.edu.tw -update
>>手動更新紀錄檔其中--config=cna.kyit.edu.tw記得改成你的domain name
Update for config "./awstats.cna.kyit.edu.tw.conf"
With data in log file "/var/log/httpd/access_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)...r />
Jumped lines in file: 0
Parsed lines in file: 2
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 2 new qualified records.
>>如果出現這樣的訊息的話,那就表示記錄檔更新成功了。
# vi /etc/cron.hourly/awstats.sh
>>將更新紀錄檔的程式寫入排程,每小時執行一次
#! /bin/bash
/var/www/cgi-bin/awstats/awstats.pl -config=cna.kyit.edu.tw -update > /dev/null<
br />
>>內容如上述兩行
(7)觀看你的httpd紀錄檔分析成果
http://cna.kyit.edu.tw/cgi-bin/awstats/awstats.pl?config=cna.kyit.edu.tw
(8)設定ftp記錄檔分析
# cp awstats.model.conf awstats.ftp.conf
>>複製一份設定檔
# chmod 755 awstats.ftp.conf
>>修改讀寫權限
# vi /etc/proftpd.conf
>>修改proftp記錄檔的內容,使他成為可以被讀取的格式
>>在此檔案內加入,下面三行
LogFormat awstats "%t %h %u %m %f %s %b"
ExtendedLog /var/log/xferlog read,write awstats
TransferLog none
# /etc/rc.d/init.d/proftpd restart
>>重新啟動proftpd
# rm -f /var/log/xferlog
>>刪除原先舊有的紀錄檔,新的記錄檔應該者的像這樣
[01/Jan/2001:21:49:57 +0200] ftp.server.com user RETR /home/fileiget.txt 226 149
9
(10)設定awstats.ftp.conf
#vi awstats.ftp.conf
>>開啟檔案,修改設定檔的內容設定如下方列表
LogFile="/var/log/xferlog"
LogType=F
LogFormat="%time1 %host %logname %method %url %code %bytesd"
LogSeparator=" "
SiteDomain="cna.kyit.edu.tw"
DirData="./data"
DirIcons="/awstats/icon"
NotPageList=""
LevelForBrowsersDetection=0
LevelForOSDetection=0
LevelForRefererAnalyze=0
LevelForRobotsDetection=0
LevelForSearchEnginesDetection=0
ShowLinksOnUrl=0
ShowMenu=1
ShowMonthStats=UVHB
ShowDaysOfMonthStats=HB
ShowDaysOfWeekStats=HB
ShowHoursStats=HB
ShowDomainsStats=HB
ShowHostsStats=HBL
ShowAuthenticatedUsers=HBL
ShowRobotsStats=0
ShowEMailSenders=0
ShowEMailReceivers=0
ShowSessionsStats=1
ShowPagesStats=PBEX
ShowFileTypesStats=HB
ShowFileSizesStats=0
ShowBrowsersStats=0
ShowOSStats=0
ShowOriginStats=0
ShowKeyphrasesStats=0
ShowKeywordsStats=0
ShowMiscStats=0
ShowHTTPErrorsStats=0
ShowSMTPErrorsStats=0
(11)分析記錄更新
# ./awstats.pl -config=ftp -update
>>手動更新紀錄檔其中--config=ftp不用改,然後會出現如下的訊息
Update for config "./awstats.ftp.conf"
With data in log file "/var/log/xferlog"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Jumped lines in file: 0
Parsed lines in file: 2
Found 0 dropped records,
Found 2 corrupted records,
Found 0 old records,
Found 0 new qualified records.
>>如果出現這樣的訊息的話,那就表示記錄檔更新成功了。
# vi /etc/cron.hourly/awstats.sh
>>將更新紀錄檔的程式寫入排程,每小時執行一次
/var/www/cgi-bin/awstats/awstats.pl -config=ftp -update > /dev/null
>>由於剛剛以建立此檔案,所以現在者需加入上面一行即可
(12)觀看你的ftp紀錄檔分析成果
http://cna.kyit.edu.tw/cgi-bin/awstats/awstats.pl?config=ftp
(13)設定mail log分析
# cp awstats.model.conf awstats.mail.conf
>>複製一份設定檔
# chmod 755 awstats.mail.conf
>>修改讀寫權限
(14)設定awstats.mail.conf
#vi awstats.mail.conf
>>開啟檔案,修改設定檔的內容設定如下方列表
LogFile="perl /var/www/cgi-bin/awstats/tools/maillogconvert.pl standard g/mail/info |>
>>這裡的/var/log/mail/info即為你的postfix記錄檔
LogType=M
LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd"
>
SiteDomain="cna.kyit.edu.tw"
DirData="./data"
DirIcons="/awstats/icon"
LevelForBrowsersDetection=0
LevelForOSDetection=0
LevelForRefererAnalyze=0
LevelForRobotsDetection=0
LevelForSearchEnginesDetection=0
LevelForFileTypesDetection=0
ShowMenu=1
ShowMonthStats=HB
ShowDaysOfMonthStats=HB
ShowDaysOfWeekStats=HB
ShowHoursStats=HB
ShowDomainsStats=0
ShowHostsStats=HBL
ShowAuthenticatedUsers=0
ShowRobotsStats=0
ShowEMailSenders=HBL
ShowEMailReceivers=HBL
ShowSessionsStats=0
ShowPagesStats=0
ShowFileTypesStats=0
ShowFileSizesStats=0
ShowBrowsersStats=0
ShowOSStats=0
ShowOriginStats=0
ShowKeyphrasesStats=0
ShowKeywordsStats=0
ShowMiscStats=0
ShowHTTPErrorsStats=0
ShowSMTPErrorsStats=1
(15)分析記錄更新
#./awstats.pl -config=mail -update
>>手動更新紀錄檔其中--config=mail不用改,然後會出現如下的訊息
Update for config "./awstats.mail.conf"
With data in log file "perl /var/www/cgi-bin/awstats/tools/maillogconvert.pl st
andard < /var/log/mail/info |"...
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)...r />
Jumped lines in file: 0
Parsed lines in file: 226
Found 0 dropped records,
Found 16 corrupted records,
Found 0 old records,
Found 210 new qualified records.
>>如果出現這樣的訊息的話,那就表示記錄檔更新成功了。
# vi /etc/cron.hourly/awstats.sh
>>將更新紀錄檔的程式寫入排程,每小時執行一次
/var/www/cgi-bin/awstats/awstats.pl -config=cna.kyit.edu.tw -update > /dev/null<
br />
>>由於剛剛以建立此檔案,所以現在者需加入上面一行即可
(16)觀看你的ftp紀錄檔分析成果
http://cna.kyit.edu.tw/cgi-bin/awstats/awstats.pl?config=mail
(17)備註
>> 在/etc/cron.hourly/awstats.sh的設定檔內容如下
#! /bin/bash
/var/www/cgi-bin/awstats/awstats.pl -config=cna.kyit.edu.tw -update > /dev/null<
br />
/var/www/cgi-bin/awstats/awstats.pl -config=ftp -update > /dev/null
/var/www/cgi-bin/awstats/awstats.pl -config=mail -update > /dev/null
(18)大致完成了,有問題在告訴我巴!!歡迎轉載,如有錯誤也請你告訴我!! thx
mtchang@cna.kyit.edu.tw

?w?????????????O^^ http://holy.be
???j?a?????????i???????W??, thanks^^
|
|
|
 |
|
 |
|
|
|
 |
|
 |
|
|
文章主題:
發表於: 2004-01-31 16:54
|
|
some 在裝這套perl軟體時發現教學有個地方不合
| 代碼: |
| .awstats.pl -config=xxxxx -update |
而設定檔頭一定要有個 awstats 檔尾 conf ,所以打
| 代碼: |
| .awstats.pl -config=xxxxx -update |
它找的是 awstats.xxxxx.conf 這個檔..檔名可別設錯囉~~ 

?w?????????????O^^ http://holy.be
???j?a?????????i???????W??, thanks^^
|
|
|
 |
|
 |
|
|
|
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 可以 在這個版面附加檔案 您 可以 在這個版面下載檔案
|
|