天天看點

squid命中率監控軟體squid-graph

本文原創 轉載說明  更新日期:08年1月12日 環境:centos5.1

http://sourceforge.net/projects/squid-graph

解壓縮,安裝

#tar zxvf squid-graph-3.2.tar.gz

#mv squid-graph /usr/local/

2.安裝perl的GD包

安裝rpm擴充包,安裝方法見我的"rpm進階管理技巧"

#yum -y install perl-GD-Graph perl-GD

3.配置httpd伺服器

#mkdir -p /var/www/squid-graph

編輯httpd的配置文檔

# vim /etc/httpd/conf.d/squid-graph.conf

在加入

Alias /squid-graph /var/www/squid-graph

<Location /squid-graph>

Order deny,allow

Allow from all

Deny from all

Allow from 127.0.0.1

Allow from ::1

</Location>

4.安裝完,分析

使用以下指令來分析

#/usr/local/squid-graph/squid-graph -o=/var/www/squid-graph/ < /var/log/squid/access.log

還可以設定自動使用cron,每5分鐘執行一次

#crontab -e

*/5 * * * * /usr/local/squid-graph/squid-graph -o=/var/www/squid-graph/ < /var/log/squid/access.log

到此結束,然後通過浏覽器通路 http://ip/squid-graph/index.html

注:squid的日志要使用squid原本的格式,和emulate_httpd_log on ,有人講這行一定要注釋掉,不然程式分析不出來.記的要設定安全哦,不能讓任何人都能打開哦