配置日志分析: yum install httpd gd -y //安裝http和GD庫 把sarg包拉入 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 //建立不生成報告的主機列表文件 ls
ln -s /usr/local/sarg/bin/sarg /usr/local/bin/ //建立軟連接,方便環境變量PATH識別 sarg //直接輸
出現如圖,表示正常運行 systemctl start httpd 在windows瀏覽器中輸入 http://192.168.80.100/squid-reports/