「SARG」の設定

「SARG」を用いて「Squid」のログ解析を行います。
なお、「Apache」の設定「Squid」の設定は完了済みとします。

「SARG」のインストール

「GDライブラリ」のインストール

「SARG」は「GDライブラリ」を利用しますが、USEフラグでpngを無効にしている場合、有効にします。

Gentoo ~ # vi /etc/portage/package.use <= 設定ファイルの編集
media-libs/gd png <= 追加


Gentoo ~ # emerge gd <= 「GDライブラリ」のインストール

「SARG」のインストール

Gentoo ~ # emerge sarg
「SARG」の設定
Gentoo ~ # vi /etc/sarg/sarg.conf <= 設定ファイルの作成
#language English
↓
language Japanese <= 変更

#output_dir /var/www/localhost/htdocs/squid-reports
↓
output_dir /var/www/localhost/squid-reports <= 「SARG」の出力先を指定

#charset Latin1
↓
charset Japan <= charsetを指定

ディレクトリの作成

「SARG」が出力するディレクトリを作成します。

Gentoo ~ # mkdir /var/www/localhost/squid-reports

日本語ファイルの設定

「SARG」の日本語の設定ファイルがおかしいので修正します。

Gentoo ~ # vi /etc/sarg/languages/Japanese <= 設定ファイルの編集
"Abuse レポート" <= 削除

"Making Abuse report" <= 削除

"Squid Abuse Report" <= 削除

"Authentication failures"
"拒否" <= 追加
"トップサイト" <= 追加
"SQUIDGUARD"

"Sarg log format"
"ダウンロード" <= 追加
"Graphic"
「Apache」の設定

「SARG」の設置されているディレクトリにアクセスできるように設定します。

Gentoo ~ # vi /etc/apache2/httpd.conf <= 設定ファイルの編集
以下を追加
Alias /squid-reports "/var/www/localhost/squid-reports"

<Directory "/var/www/localhost/squid-reports">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

「Apache」を再起動し、設定を反映させます。

Gentoo ~ # /etc/init.d/apache2 restart
「SARG」の実行
Gentoo ~ # sarg

http://サーバのIPアドレス/squid-reports
でアクセスできれば問題ありません。

「SARG」の自動実行

「Squid」のログローテーションに合わせて実行するようにします。

Gentoo ~ # vi /etc/cron.weekly/squid.cron <= ローテーションファイルの編集
中身を以下のように変更
if test -e /var/run/squid.pid ; then
        if test -n "$(cat /var/run/squid.pid|xargs ps -p|grep squid)" ; then
                if test -x /usr/sbin/sarg ; then
                        /usr/sbin/sarg > /dev/null 2>&1
                fi
                /usr/sbin/squid -k rotate
        fi
fi
▲ページのトップへ