FreeBSD/swatch の変更点
*swatch [#jcadc0b0]
ログの自動監視ツール
#contents
**インストール [#tb989a57]
# cd /usr/ports/security/swatch
# make install clean
**/etc/rc.conf[#x1ae37db]
# swatch
swatch_enable="YES"
swatch_rules="1"
swatch_1_flags="--config-file=/usr/local/etc/swatch1.conf --awk-field-syntax --tail-file=/var/log/messages --daemon --pid-file=/var/run/swatch_1.pid"
swatch_1_pidfile="/var/run/swatch_1.pid"
**swatchオプション [#o2fa4606]
--awk-field-syntax $0や$1の変数が使えるようになります。
**/usr/local/etc/swatch.conf [#r3c00e07]
|Action|解説|h
|echo [modes]|ウインドウにメッセージを表示|
|bell [N]|ビープ音をN回鳴らす|
|exec command|”command”を実行する|
|mail [address=xxx@xxx.jp:xxx@xx...]|指定したアドレスにメールを送信する|
|pipe command [,keep_open]|パイプで”command”に結果を返す|
|write [user:user:...]|writeコマンドを使って指定したユーザに通知を行う|
|throtte hours:minites:seconds, [use=message or regex]|同じメッセージが検出された場合、指定した時間まで通知を行わない|
|continue|指定したパターンを見つけても処理を終了せず、続けて処理を行う|
|quit|Swatchを終了させる|
**設定ファイルの書式 [#i647acc6]
watchfor /パターン/
アクション1
アクション2
……
パターンの後ろにiを付けると、パターンの大文字・小文字を区別しなくなります。(例:/ssh/i)
***最近多いDosアタックを検知するとIPFでアクセス拒否にする例 [#e716df90]
watchfor /skin\/skin\/skin/
exec "echo '@1 block in quick from $1 to any' | /sbin/ipf -f -"
exec "echo $1 Access Stop."
**/usr/local/etc/rc.d/swatch.shの編集 [#i01671f6]
初期のシェルでstopをかけると下記のエラーでpidfileを認識してくれません。
# /usr/local/etc/rc.d/swatch.sh stop
swatch not running? (check /var/run/swatch_1.pid).
■procnameの個所をコメントアウトすると正常にsotpしてくれます。
# chmod 755 /usr/local/etc/rc.d/swatch.sh
# vi /usr/local/etc/rc.d/swatch.sh
command=/usr/local/bin/swatch
procname=/usr/local/bin/perl
↓
command=/usr/local/bin/swatch
#procname=/usr/local/bin/perl