歡迎您光臨本站 註冊首頁

AWStats分析postfix日誌(這個文章很詳細所以轉過來)

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

AWStats分析postfix日誌(這個文章很詳細所以轉過來)

【前言】
AWStats是一套免費及功能強大的Log分析軟體,它可以透過CGI及Command line的方式來產生報表。

它支援了以下的Log格式

(1)Apache-combined log(XLF/ELF)
(2)Apache or Squid-common log(CLF)
(3)IIS 5.0/6.0-W3C log
(4)大部份的Web/Wap/Proxy/Streaming Servers(Apache 1.3.x and 2.x, IIS 5.0 and 6.0, WebStar, WebLogic, WebSite, Windows Media Server, Tomcat, Squid, Sambar,Roxen, Resin, RealMedia server, Oracle9iAS, Lotus Notes/Domino, Darwin, IPlanet, IceCast, ZeroBrand, Zeus, Zope,
Abyss..)
(5)FTP Server(ProFTP...)
(6)Mail Server(Postfix/Sendmail/QMail/Mdaemon/www4mail...)


支援平台

(1)Windows 2000/NT4/Me、Linux、Macintosh、Solaris、Aix、BeOS、FreeBSD
(2)ActivePerl 5.6/5.8、Perl 5.6/5.8


=========================================
作者: zoob ([email protected])

版權聲明:可以任意轉載,轉載時請務必標明原始出處和作者資訊

【安裝AWStats】

(1)請先從官方網址 ( http://awstats.sourceforge.net/ ) 下載AWStats ( http://prdownloads.sourceforge.net/awstats/awstats-6.1.tgz )

(2)解壓縮 awstats-6.1.tgz

(3)將解壓縮出來的 tools 及 wwwroot 目錄複製到 /usr/local/awstats 目錄下

(4)切換目錄至 /usr/local/awstats 目錄

(5)執行 tools 目錄下的 configure.pl

代碼:
tools/configure.pl


(6)設定config檔
----- AWStats configure 1.0 (build 1.32) (c) Laurent Destailleur -----
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to 'understand' all possible ways to use AWStats...
Read the AWStats documentation (docs/index.html).

-----> Running OS detected: Linux, BSD or Unix

-----> Check for web server install

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path ('none' to skip web server setup):
> /etc/httpd/conf/httpd.conf <-----輸入httpd.conf的絕對路徑

-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'
AWStats directives already present.

-----> Update model config file '/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf'
File awstats.model.conf updated.

-----> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) ?y

-----> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
> www.myunix.idv.tw <-------- 輸入你所要建立的WebSite name

-----> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=wwww.myunix.idv.tw
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue...

A SIMPLE config file has been created: /etc/awstats/awstats.wwww.myunix.idv.tw.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for 'wwww.myunix.idv.tw' with command:
> perl awstats.pl -update -config=wwww.myunix.idv.tw
You can also read your statistics for 'wwww.myunix.idv.tw' with URL:
> http://localhost/awstats/awstats.pl?config=wwww.myunix.idv.tw

Press ENTER to finish...

(7)以上步驟完成後,會在/etc/awstats目錄下建立一檔案- awstats.www.myunix.idv.tw.conf

(8)建立 /var/lib/awstats 目錄,並給予 777 之權限
註:若不給予777權限,將來若設定 AllowToUpdateStatsFromBrowser=1 時,會無法透過Browser來即時更新Report

(9)設定 httpd.conf,檢查在httpd.conf中是否有以下設定,如果沒有的話,請自行加入,並且重新啟動httpd服務

代碼:
#
# Directives to add to your Apache conf file to allow use of AWStats as a CGI.
# Note that path "/usr/local/awstats/" must reflect your AWStats install path.
#
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory> 【分析 Mail Log-Postfix/Sendmail/Qmail/MDaemon】
適用於:Postfix/Sendmail/Qmail/MDaemon

(1)設定awstats.mail.myunix.idv.tw.conf

代碼:
LogFile="perl /usr/local/awstats/tools/maillogconvert.pl standard < /var/log/maillog |"  <----請指定你mail log file的絕對路徑及log名稱
LogType=M <---- M代表分析類型為mail log files
LogFormat="%time2 %email %email_r %host %host_r %method %url %code %bytesd"
SiteDomain="mail.myunix.idv.tw" <----指定定從log檔中過濾符合SiteDomain的記錄
HostAliases="myunix.idv.tw mail.myunix.idv.tw localhost 127.0.0.1" <-----指定哪些Domain或ip address為Local,其餘皆視為External
LevelForBrowsersDetection=0
LevelForOSDetection=0
LevelForRefererAnalyze=0
LevelForRobotsDetection=0
LevelForWormsDetection=0
LevelForSearchEnginesDetection=0
LevelForFileTypesDetection=0
ShowMenu=1
ShowMonthStats=HB
ShowDaysOfMonthStats=HB
ShowDaysOfWeekStats=HB
ShowHoursStats=HB
ShowDomainsStats=0
ShowHostsStats=HBL
ShowAuthenticatedUsers=0
ShowRobotsStats=0
ShowEMailSenders=HBML
ShowEMailReceivers=HBML
ShowSessionsStats=0
ShowPagesStats=0
ShowFileTypesStats=0
ShowFileSizesStats=0
ShowBrowsersStats=0
ShowOSStats=0
ShowOriginStats=0
ShowKeyphrasesStats=0
ShowKeywordsStats=0
ShowMiscStats=0
ShowHTTPErrorsStats=0
ShowSMTPErrorsStats=1



設定完畢,請存檔

(2)執行awstats.pl,記得指定設定檔時,不要輸入設定檔名前面的 awstats. 及 .conf

代碼:
# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=mail.myunix.idv.tw -update


如果出現以下訊息,就代表執行成功


Update for config "/etc/awstats/awstats.mail.myunix.idv.tw.conf"
With data in log file "perl /usr/local/awstats/tools/maillogconvert.pl standard < /var/log/maillog |"...
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: 358
Found 0 dropped records,
Found 0 corrupted records,
Found 358 old records,
Found 0 new qualified records.


(3)開啟Browser,輸入 http://www.xxx.xxx/awstats/awstats.pl?config=mail.myunix.idv.tw ,便可檢視你剛剛所產生的報表了。

Demo Site

(4)記得將步驟(2)的指令設定在crontab,讓它定期產生Log Report
《解決方案》

很好的東西為什麼沒人頂呢?
《解決方案》

好文,馬上測試下。。。
《解決方案》

AWStats非常不錯

[火星人 ] AWStats分析postfix日誌(這個文章很詳細所以轉過來)已經有2258次圍觀

http://coctec.com/docs/service/show-post-27709.html