配置日誌分析:
yum install httpd gd -y //安裝http和GD庫
tar xf sarg-2.3.11.tar.gz -C /opt/ //解壓日誌分析軟件包
cd /opt/sarg-2.3.11/ //進入解壓後的文件夾中定義
./configure \
--prefix=/usr/local/sarg \ //指定安裝路徑
--sysconfdir=/etc/sarg \ //配置文件目錄,默認是/usr/local/etc
--enable-extraprotection //添加額外的安全保護
make && make install
vi /etc/sarg/sarg.conf //配置
搜索並修改一下內容:
access_log /usr/local/squid/var/logs/access.log //squid的訪問日誌位置
title "Squid User Access Reports" //網頁標題
output_dir /var/www/html/squid-reports //分析報告的存放位置
user_ip no //不使用IP代替用戶ID
topuser_sort_field BYTES reverse //升序排列
user_sort_field BYTES reverse
//在top排序中,指定連接次數、訪問字節數,採用降序排列,升序將reverse換爲normal
exclude_hosts /usr/local/sarg/noreport //設置不生成報告的主機
overwrite_report no //當那個日期報告已存在,不覆蓋
mail_utility mailx //指定發郵件命令
charset UTF-8 //使用字符集
weekdays 0-6 //指定top排序星期週期
hours 7-12,14,16,18-20 //指定top排序時間週期
www_document_root /var/www/html //網頁根目錄
touch /usr/local/sarg/noreport //建立不生成報告的主機列表文件
ln -s /usr/local/sarg/bin/sarg /usr/local/bin/ //建立軟連接,方便環境變量PATH識別
sarg //直接輸
出現如圖,表示正常運行
systemctl start httpd
在windows瀏覽器中輸入http://192.168.80.102/squid-reports/