2007年12月7日金曜日

darkstat

GIGAZINE で darkstat とゆーのが紹介されてたのでいれてみた。

% sudo apt-get install darkstat

バージョン古い。。
% darkstat --version
darkstat v2.6 using libpcap v2.4 (i486-pc-linux-gnu)
Copyright (C) 2001-2003, Emil Mikulic.
http://purl.org/net/darkstat

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.


起動。
バージョン違うからか、GIGAZINEの記事とは違って、
・デフォルト port が 666 (!)
・バックグラウンドには移行しない (--detach つければする)

ポートさらすのはいやなので 127.0.0.1 で bind してみた
(ssh でポートフォワードして見るの)
% darkstat -i eth0 -b 127.0.0.1
darkstat v2.6 using libpcap v2.4 (i486-pc-linux-gnu)
Binding webserver to 127.0.0.1
Firing up threads...
Sniffing on device eth0, local IP is xxx.xxx.xxx.xxx
GRAPH: Starting at 15 secs, 38 mins, 13 hrs, 7 days.
Loaded darkstat.db.
DNS: Thread is awake.
WWW: Thread is awake and awaiting connections.
WWW: You are using the English language version.
ACCT: Capturing traffic...
Point your browser at http://localhost:666/ to see the stats.

ポートフォワード (Mac OS X上)
端末はいらんので -T をつけるのが大人。
% ssh -T 対象サーバ -Lにんいのぽーと:localhost:666

はい、みれました。


darkstat を ctrl-c でとめ。
Caught SIGTERM, syncing threads...

Syncing... 3 threads (acct) (dns) (www)
ACCT: Out of capture loop.
DNS: Thread down.
^PSyncing... 1 thread (www)
WWW: Thread down.
Caught a redundant SIGTERM. Still waiting for:
Synced! Dumping DB...done!
Can't unlink pidfile: Bad address

記事中、kill -9 が書いてあったのが不思議だったけど
SIGTERM で止まるよね。
Can't unlink pidfile: Bad addressはちょっと気になるけど放置。

daemontools の supervise下で起動させるのもよさそう。

-- その後
バージョン 3.0.707 の debパケージを作ってそっちに入れ替えた。
作り方の勝手がよくわからず、ぐぐりつつ適当にコマンドたたいてたらできたけどよくわかってない。
・起動スクリプトない (前述の supervise 配下にした)
・やっぱりデフォルトポートは 667
・フォアグラウンドで動かすには --debug
・rootの権限は捨ててくれる (nobody になった)

0 件のコメント:

コメントを投稿