SSブログ

Squid Graph (FreeBSD 8.1R、2010/08/02) [FreeBSD]

Squidのアクセスログをグラフ化するSquid Graph(http://sourceforge.net/projects/squid-graph/)を使ってみました。最初はportsにないものかと探してみたのですが、結論から言うとないです。…と言うより、portsにするまでもなく導入が簡単過ぎでした。展開してオプション指定で実行、たったそれだけです。

STDINで1行エラーが出てますが、newsyslogのこのメッセージの影響です。無視して解析してくれるみたいですね。
Aug  2 00:00:00 atom newsyslog[28170]: logfile turned over

グラフ生成はスクリプト実行タイミングとなりますが、シェルスクリプトCGIにてWeb上からもグラフ生成スクリプトを実行することもできます。Web上からCGIにて実行する際、一つ気をつけないといけないのは、ower、groupのパーミッションでしょうか。WWWサーバはwww(owner)で起動しており、CGIの実行もwww権限となります。それに対して/var/log/squid-access.logのアクセスパーミッションを適切に設定しないと、権限不足で読み込むことができずグラフ出力されません。
最初はちょっと分からず悩みました。結局、セキュリティ上otherに対して/var/log/squid-access.logにreadパーミッションを与えるわけも行かず、cronにてグラフ生成スクリプトを定時実行することにしてみました。
atom# ./squid-graph --output-dir=/tmp/squid-graph < /var/log/squid-access.log
[Sun Aug  1 01:28:47 2010] Squid-graph 3.2 release OK. Program started.
[Sun Aug  1 01:28:47 2010] Graph domain is 86400 seconds.
[Sun Aug  1 01:28:47 2010] Setting report title to "Squid Graph Logfile Analysis Report".
[Sun Aug  1 01:28:47 2010] Configured for default histograms.
[Sun Aug  1 01:28:47 2010] Configured have_tcp and have_udp.
[Sun Aug  1 01:28:47 2010] Transfer duration graph(s) enabled.
[Sun Aug  1 01:28:47 2010] Configured start time to 1280507327.
[Sun Aug  1 01:28:47 2010] Reading STDIN for logfile input.
[Sun Aug  1 01:28:47 2010] Invalid log data at line 1. Error #1.
[Sun Aug  1 01:28:47 2010] Calculating averages for TCP/UDP transfer duration.
[Sun Aug  1 01:28:47 2010] Done reading 2109 lines from logfile on STDIN. (1 errors)
[Sun Aug  1 01:28:47 2010] Analysis duration is 1 seconds, 2109 lines/sec.
[Sun Aug  1 01:28:47 2010] Creating TCP image objects.
[Sun Aug  1 01:28:47 2010] Creating UDP image objects.
[Sun Aug  1 01:28:47 2010] Plotting graph of TCP accesses.
[Sun Aug  1 01:28:47 2010] Plotting graph of TCP transfers.
[Sun Aug  1 01:28:47 2010] Plotting graph of TCP transfer duration.
[Sun Aug  1 01:28:47 2010] Plotting graph of UDP accesses.
[Sun Aug  1 01:28:47 2010] Plotting graph of UDP transfers.
[Sun Aug  1 01:28:47 2010] Plotting graph of UDP transfer duration.
[Sun Aug  1 01:28:47 2010] Writing to file /tmp/squid-graph/tcp-access.png
[Sun Aug  1 01:28:47 2010] Writing to file /tmp/squid-graph/tcp-transfer.png
[Sun Aug  1 01:28:47 2010] Writing to file /tmp/squid-graph/tcp-duration.png
[Sun Aug  1 01:28:47 2010] Writing to file /tmp/squid-graph/udp-access.png
[Sun Aug  1 01:28:47 2010] Writing to file /tmp/squid-graph/udp-transfer.png
[Sun Aug  1 01:28:47 2010] Writing to file /tmp/squid-graph/udp-duration.png
[Sun Aug  1 01:28:47 2010] Gathering additional statistics.
[Sun Aug  1 01:28:47 2010] Writing index.html file.
[Sun Aug  1 01:28:48 2010] Done.
[Sun Aug  1 01:28:48 2010] Remember to copy logo.png found in your Squid Graph images/ directory to /tmp/squid-graph!

20100802_squid-graph.png

タグ:squid

共通テーマ:日記・雑感