︿
Top

1、前言

pwebstats 為一用來分析 Squid Log 進而了解目前 Proxy Server 狀況及 Proxy Client 行為的套件。






文章目錄

1、前言
2、實作環境
3、安裝及設定
          步驟1.安裝 pwebstats 套件
          步驟2.修改 pwebstats 設定檔 (squid-proxy.conf)
          步驟3.執行 pwebstats 流量統計
          步驟4.設定排程
4、參考




2、實作環境

  • FreeBSD 7.x 
  • pwebstats-1.3.8_1




3、安裝及設定

步驟 1. 安裝 pwebstats 套件

切換至 Ports Tree 下開始安裝 pwebstats 套件。
cd /usr/ports/www/pwebstats     //切換至安裝路徑
make install clean               //安裝並清除暫存檔案




步驟 2. 修改 pwebstats 設定檔 (squid-proxy.conf)

修改 pwebstats 設定檔 squid-proxy.conf 內容如下 (以下設定檔內容為此次實作範例,實際情形請依個人環境自行設定),其中分析間隔  interval 支援 daily, weekly, monthly, quarterly 等方式。
cp -rp /usr/local/etc/pwebstats /home/web/     //將目錄複製至 /home/web 資料夾下
vi /home/web/pwebstats/conf/squid-proxy.conf   //修改設定檔 (其餘採用預設值)
 server:www.weithenn.org                    //指定 Proxy Server 名稱
 Server_header:The Proxy Log Analysis       //指定分析頁面 Title
 logfile:/home/web/logs/squid/access.log.0  //指定 Squid Log 路徑
 logtype:squid                              //指定 Log 類型
 outdir:/home/web/pwebstats                 //指定分析結果存放路徑
 templates:/home/web/pwebstats/templates    //指定模組路徑
 interval:daily                             //指定分析間隔為每日
 fly_prog:/usr/local/bin/fly                //指定 fly 執行檔路徑




步驟 3. 執行 pwebstats 流量統計

cd /home/web/pwebstats                  //切換至 pwebstats 執行檔路徑
./pwebstats -c conf/squid-proxy.conf  //執行 pwebstats 流量統計
 =====================================================
 pwebstats 1.3.8 started at 12:22:28 on 10 August 2009.
 =====================================================
 -- Reading in previous days' details.
 -- Reading in log file /home/web/logs/squid/access.log.0:
    The logfile has 21530 entries.
    Processing...
    0%                     50%                      100%
    |-----------------------|------------------------|
    #################################################
    Finished.
 -- Building {host,domain,item}/accesses Arrays:
    Host threshold is 25
    Domain threshold is 5
    Item threshold is 25
   Building Hosts/Accesses Array...done.
   Building Domains/Accesses Array... done.
   Building Remote Hosts/Accesses Array...  done.
   Building Protocol Summary Array... done.
   Summarising Requests by Hour... done.
 -- Writing Out Cumulative Details.
 -- Writing Index page.
 -- Writing stats pages & graphs:
    This day's stats page.
    Hourly Stats Page.
    All Hosts Page.
    All Domains Page.
    Remote sites page.
 -- Creating graphs and charts...
     Growth in accesses line graph
     Domain pie chart
     Hourly bar graph
 ======================================================
 pwebstats 1.3.8 finished at 12:22:30 on 10 August 2009.
 ======================================================




步驟 4. 設定排程

修改排程使系統每天早上六點半自動執行分析 Squid Log 的工作。
crontab -e
 30 6 * * * /home/web/pwebstats/pwebstats -c /home/web/pwebstats/conf/squid-proxy.conf 






4、參考

文章標籤: