Pwebstats介紹及安裝

原作: 李政其

最後修改日期: 2003/4/23

發展簡介

功能簡介及下載

安裝說明

系統設定檔

圖表說明

維護與管理

 

發展簡介

Pwebstats作者為Martin Gleeson,目前版本是西元1999年9月9日所發佈的Pwebstats 1.3.8 版。Pwebstats是使用Perl程式所撰寫的,此套工具程式可以分析-通用紀錄格式(Common Log Format)的http log,或是分析proxy server log。執行pwebstats程式還需要先行安裝fly程式以及gd函式庫。pwebstats是用來解析Proxy Squid的access.log檔案,而fly程式及gd函式庫主要是用來產生圖表。經過運作處理之後,會產生html格式的檔案以及圖形,以紀錄proxy or http server log的結果。

此套工具程式對於教育單位以及非營利事業單位是免費的,在網路上可以下載此套工具軟體。在這範圍內的使用者可以任意修改程式內容,但是必須要將連結到pwebstats網頁資訊保存。

版本歷史(參考原始網站)

Version: 1.3.8 9 September 1999
Addition: re-generate index page if it is zero-sized due to full disk on last run. Thanks to Stephen Stebbing <s.stebbing@its.unimelb.edu.au>.

Version: 1.3.7 23 November 1998
Minor Change: allow ':' in last field of page-config format. (以下略)

功能簡介及下載

Pwebstats分析內容

Requests Satisfied by the cache

Requests Proxied

Total number of requests served

Bytes sent for cache requests

Bytes sent for proxy requests

Total number of bytes sent

Cache Hit Rate

Requests

Bytes

Number of Mb sent by this server

Number of hosts using this server

Average number of requests/day

Average number of requests/hour

Average number of requests/minute

Hosts accessing this server, ordered by number of accesses

Top Ten Hosts

Remote sites accessed by this server, ordered by number of accesses

Top Ten Sites

Protocols proxied, ordered by number of requests

Accesses to remote servers, by domain of remote server

Unresolved means IP numbers which do not resolve to hostnames

Number of Accesses Per Day during this period

Average Number of Accesses Per Hour of the Day

Peak hour

Man Site

http://martin.gleeson.com/pwebstats/

http://www.gleeson.net/fly/

Pwebstats Download Site

ftp://ftp.unimelb.edu.au/pub/www/tools/unix/pwebstats/pwebstats-1.3.8.tar.Z

ftp://ftp.psg.com/pub/pwebstats/pwebstats-1.3.8.tar.Z

Fly Download Site

Fly Stable Version http://www.gleeson.net/fly/dist/fly-2.0.0.tar.Z

Fly Old Version http://www.gleeson.net/fly/dist/fly-1.6.5.tar.gz

Gd Graphics Library Download Site

Gd Stable Version http://www.boutell.com/gd/http/gd-2.0.11.tar.gz

Gd Old Version http://www.boutell.com/gd/http/gd-1.8.4.tar.gz

安裝說明

Pwebstats安裝流程如下:

1. 請先安裝Perl version 5.000或是高於此版本。

2. 確定系統是否有Apache Web Server。

3. 確定系統是否有Gd函式庫。

4. 下載以及安裝Fly程式,我們使用fly-1.6.5版本(附有Gd1.3函式庫)。

5. 下載以及安裝Pwebstats程式。

6. 執行pwebstats程式。

7. Proxy log分析完成。

Pwebstats安裝詳細敘述如下(以Proxy4 Server為例):

1. 確定perl版本以及gd函式庫。指令如下:

rpm -qa gd

rpm -qa perl

2. 將下載完成的Fly以及Pwebstats進行解壓縮,個人是將這兩個檔案解壓縮到/home底下。指令如下:

#複製到/home 目錄

cp fly-1.6.5.tar /home

cp pwebstats-1.3.8.tar.gz /home

cd /home

#解壓縮程序

tar -xvf fly-1.6.5.tar

tar -zxvf pwebstats-1.3.8.tar.gz

#更改資料夾名稱

mv fly-1.6.5 fly

mv pwebstats-1.3.8 pwebstats



3. make fly程式

進入到fly資料夾之後,執行make指令,會編譯出fly的執行程式檔案,若是沒有此一檔案,則會出現錯誤訊息,無法進行pwebstats程式。若系統已經安裝fly函式庫,則可以掠過此一步驟。

cd /fly

make

4. 修改Pwebstats設定檔案。指令如下所示

#切換到pwebstats底下conf目錄

cd /home/pwebstats/conf

#使用pico程式編輯修改squid設定檔案

pico squid-proxy.conf

需要修改部分說明如squid-proxy.conf設定

5. 編修調整Pwebstats主程式,此一步驟依個別需求而定,可不編修。

#切換到pwebstats目錄

cd /home/pwebstats

#使用pico程式編輯修改pwebstats可執行檔案,依照個人需求而編修程式主體

pico pwebstats

6. 執行Pwebstats程式。其執行指令如下所示

#切換到pwebstats目錄,準備執行程式

cd /home/pwebstats

#執行pwebstats程式

./pwebstats –c /home/pwebstats/conf/squid-proxy.conf

7. 在Browser上輸入IP address或是host domain name,就可以瀏覽結果。

http://210.240.249.1/

8. 若是要讓系統每天固定執行,則可以執行下列指令

cd /etc

pico crontab

#crontab格式說明:

#min hour date month week user orders

#下面這一行會自動於每天的3點執行pwebstats分析proxy log


03***root /home/pwebstats/pwebstats -c /home/pwebstats/conf/squid-proxy.conf

系統設定檔

Squid-proxy.conf編輯

squid-proxy.conf檔案

# pwebstats configuration file for http server

# Unique nickname for server.

# use only a-z, A-Z and _

# e.g. server:proxy

server:proxy

#更改為Proxy4 Server

server:Proxy4 Server




# Header for index page.

# e.g. Server_header:The TelDem Enterprises Caching Proxy Server

Server_header:

#在pwebstats中,會引用此段成為網頁Title,因此改為想要顯示的訊息

Server_header:明志技術學院代理伺服器(Proxy-4)紀錄分析




# Location of latest log file

logfile:

# default proxy log file path:/var/log/squid/access.log. ---by leeyang

#logfile填入squid system的access.log的紀錄檔案位置

#如果有輪換檔,就指定輪換檔access.log.0路徑

logfile:/var/log/squid/access.log




# Type of log file - use 'squid-emulated' if you have the httpd log

# emulation option turned on in squid.

#如果做 Proxy Server 流量分析則 squid.conf 中 emulates 設定成 off,


#否則在產生的網頁中會產生 1.網頁產生日期不正確 2> client 端資訊無法顯

#示得知

#紀錄檔案的型態按照預設值-squid即可


logtype:squid



# Location for the output of pwebstats.

# e.g. outdir:/home/servers/http/teldem/proxy-usage

outdir:/home/servers/http/teldem/proxy-usage

# Redhat 7.3 , default outdir : /var/www/html ---by leeyang

#指定pwebstats輸出結果的檔案位置,因此改成網頁預設輸出位置

outdir:/var/www/html


# directory containing GIF templates

# e.g. templates:/home/servers/http/pwebstats/templates

# We can use pwebstats's templates , so , the path of #templates:/home/pwebstats/templates -by leeyang

#指定GIF模板位置,按照pwebstats安裝的路徑指定即可

templates:/home/pwebstats/templates




# Stats collection interval

# can be one of daily, weekly, monthly, quarterly(4 months)

# we can chose daily for stats collection interval

#選擇狀態收集的間隔,一般採用-daily即可

interval:daily



# Verbose? Yes

#執行過程是否有訊息顯示。

verbose:true



# Location of 'fly'

# e.g. fly_prog:/home/servers/http/pwebstats/fly/fly

fly_prog:

#指定fly程式所在位置,即一開始安裝fly的位置

fly_prog:/home/fly-1.6.5/fly




# regular expression matching your local hostnames and IP numbers

# local host name and ip address , don't write any number here. ----by leeyang

#用來表示記錄 client 端的資訊:包含了IP 或 Hostname

#依照預設值,不需填入任何資料


# e.g. local_patt:\.unimelb\.edu\.au$|^128\.250|^localhost$|250\.128\.in\-addr\.arpa

local_patt:



# threshold for host count lists

#主機計算清單的門檻,預設值為25,可以依環境需求而更改設定

host_threshold:25



# threshold for remote host count lists

#遠端主機計算清單的門檻,預設值為25,可以依環境需求而更改設定

remote_host_threshold:25



# threshold for request count lists

#請求數清單的門檻,預設值為25,可以依環境需求而更改設定

item_threshold:25



# threshold for domain count lists

#domain計數清單的門檻,預設值為5,可以依環境需求而更改設定

domain_threshold:5



# don't generate request/accesses information

# (recommended for proxy stats)

exclude_reqs:true



# completely ignore access from this set of hostnames ( | is the delimeter)

# complete_exclude_host:foo1.users.bar.com|foo2.users.bar.com|foo3.users.bar.com

#

# You might like to add the IP numbers and/or hostnames of your squid neighbours

# so you just get the information about local users.

#complete_exclude_host:



# completely ignore access to this pattern of URLs

# complete_exclude_url_patt:^/foo/bar/*$|^/robots.txt$

#complete_exclude_url_patt:



# completely ignore access from this set of users ( | is the delimeter)

# complete_exclude_user:tom|dick|harry

#complete_exclude_user:



# do IP number -> hostname resolution

#dns_lookup:true

 

圖表說明

該天流量概況

Blue Line-Total Requests

Proxy3 Server所接到的全部請求數


Red Line-Proxy Requests

Proxy3 Server本身沒有資料,Proxy3 Server對外請求資料,再將資料傳給User


Green Line-Cache Requests

Proxy3 Server 本身已經存有的資料,Proxy3 Server直接將資料傳給User


Total Requests = Proxy Requests + Cache Requests

 

對外網域統計

主要分析透過Proxy3 Server對外通訊之網域,Unresolved代表無法解析網站所在位置

每小時流量統計

主要分析一天的流量概況,以小時為單位,並且統計尖峰時刻流量

註: 以上三個圖形取自 MIT Proxy3 Server :http://192.168.100.2

 

維護與管理

1. 每天觀看Proxy Server所發出的日誌信件,看是否有順利運作。

2. 每天瀏覽分析之結果,並且將流量異常之網站記錄,並且瀏覽該網站內容。

若為不當之網站,將名單記錄,並且發Email給管理者。

3. 記錄流量異常之主機,並且將名單記錄,並且發Email給管理者。

4. 若是發生分析出現錯誤,請確定程式是否能順利執行,並且確定squid-proxy.conf檔案設定 。

5. 若是發現無法分析檔案,先確定Proxy Log檔案access.log所在位置是否存在或是已變更。

6. 固定一個時段,備份全部網頁內容。

7. 若有需要將內容中文化,請編輯pwebstats。

8. 若是需要更改設定檔案,請先備份squid-proxy.conf。