安装lightsquid分析squid log
【前言】
[LightSquid - lite and fast log analizer for squid proxy]為利用 Squid
Access Log 來分析 Proxy Client 使用情形。當然能分析 Squid Log 的軟體不只一套有興趣的話可到 [Squid-
cache.org Squid: Logfile Analysis List] 看看。
LightSquid 特色如下: [LightSquid Analysis ScreenShot]
* fast and simple install
* fast log parser generatesmall per user data file
* perl based cgi script for dynamic generated report pages
* html template for design
* no database required
* no additional perl module
* various reports
* user groups support
* graphics report (v 1.6+)
* real name (v 1.6+)
* multilangual interface
【作業環境】
FreeBSD 6.2-RELEASE
lighttpd-1.4.18_1
lightsquid-1.7.1_1
【安裝及設定】
Step1.安裝 lightsquid 套件
#cd /usr/ports/www/lightsquid //切換至安裝路徑
#make install clean //安裝套件並清除安裝過程中產生不必要檔案
Step2.修改 lightsquid 設定檔
以下 僅列出跟預設值不同的設定 (要更進階的請自行研究吧!!),因為預設是安裝到 /usr/local/www/lightsquid 但我習慣把
東西放在 /home 下集中,所以就把目錄 cp -rp 到 /home 下吧。
#vi vi /usr/local/etc/lightsquid/lightsquid.cfg
$cfgpath =”/usr/local/etc/lightsquid”; //指定 lightsquid.cfg 設定檔路徑
$tplpath =”/home/web/lightsquid/tpl”; //指定 tpl 路徑 (存取屆時顯示 html、圖檔)
$langpath =”/usr/local/share/lightsquid/lang”; //指定語系檔路徑
$reportpath =”/home/web/lightsquid/report”; //指定分析完資料放置路徑
$logpath =”/home/log/squid”; //指定要讀取 squid log 路徑
修改完設定檔後我們可以跑一下檢查語法正 確性的指令
#/usr/local/www/lightsquid/check-setup.pl
LightSquid Config Checker, (c) 2005 Sergey Erokhin GNU GPL
LogPath : /home/log/squid
reportpath: /home/web/lightsquid/report
Lang : /usr/local/share/lightsquid/lang/eng
Template : /home/web/lightsquid/tpl/base
Ip2Name : /usr/local/libexec/lightsquid/ip2name.simple
all check passed, now try access to cgi part in browser //檢查 OK
Step3.產生 lightsquid 分析圖表
接下來為利用 lightparser.pl 分析 Squid Access Log 若分析成功會有分析資料輸到到你指令的
reportpath (此例我設的路徑為 /home/web/lightsquid/report),注意是不用打路徑只要打 access
log 名稱就好,因為會自動幫你套設定的 LogPath 路徑
#/home/web/lightsquid/lightparser.pl access.log.0 //access log 不用在打路徑了
(套用 LogPath: /home/log/squid)
Step4.連結分析結果網頁
http://your_host/lightsquid/index.cgi
因為 lightsquid 是使用 Perl Language 撰寫的而我使用的 web server 是 lighttpd 所以也要設定一下
才連得上 index.cgi 不然就是要打了,若要設定 lighttpd.conf 內容如下,修改完後記得 reload lighttpd
哦
#vi /usr/local/etc/lighttpd.conf //加上 index.cgi
index-file.names = ( “index.php”, “index.html”,
“index.htm”, “index.cgi”, “default.htm” )
Step5.加入排程自動分析
我們定於每天凌晨三點執行 squid rotate 來產生 squid access.log.0 然後凌晨四點使用 lightsquid 來分
析 squid log 檔並產生統計圖表
#crontab -e
0 3 * * * root /usr/local/sbin/squid -k rotate
0 4 * * * root /usr/local/www/lightsquid/lightparser.pl access.log.0
除注明转载的文章外,都是本人原创,转载时请加上原文链接并注明: 转载自品味生活
本文链接地址: 安装lightsquid分析squid log
Popularity: 10%
最新评论