logwatchでfreshclamのログがうまく読めない場合がある
いつも通り何気なしにDebianでlogwatchの設定をして実行してみるとclam-updateのセクションで下記の様なメッセージが表示される。
--------------------- clam-update Begin ------------------------ No updates detected in the log for the freshclam daemon (the ClamAV update process). If the freshclam daemon is not running, you may need to restart it. Other options: A. If you no longer wish to run freshclam, deleting the log file (default is freshclam.log) will suppress this error message. B. If you use a different log file, update the appropriate configuration file. For example: echo "LogFile = log_file" >> /etc/logwatch/conf/logfiles/clam-update.conf where log_file is the filename of the freshclam log file. C. If you are logging using syslog, you need to indicate that your log file uses the syslog format. For example: echo "*OnlyService = freshclam" >> /etc/logwatch/conf/logfiles/clam-update.conf echo "*RemoveHeaders" >> /etc/logwatch/conf/logfiles/clam-update.conf ---------------------- clam-update End -------------------------
ログの場所は間違っていないのでC.が有力と言う事で*RemoveHeadersを記述してみたがダメ。仕方がないので/usr/share/logwatch/scripts/services/clam-updateを見てみた。
なんてこと無い。ログの行頭に日付が入っているのが問題なだけ。通常なら*RemoveHeadersで除去出来るのだろうけどfreshclamがはき出すログは日付の最後に「->」がある。これが原因。
Sun May 15 07:25:09 2011 -> -------------------------------------- Sun May 15 08:25:09 2011 -> Received signal: wake up Sun May 15 08:25:09 2011 -> ClamAV update process started at Sun May 15 08:25:09 2011 Sun May 15 08:25:09 2011 -> main.cvd is up to date (version: 53, sigs: 846214, f-level: 53, builder: sven) Sun May 15 08:25:09 2011 -> daily.cld is up to date (version: 13078, sigs: 118061, f-level: 60, builder: guitar) Sun May 15 08:25:09 2011 -> bytecode.cvd is up to date (version: 143, sigs: 40, f-level: 60, builder: edwin)
こうなると解決方は2つ。
1./etc/clamav/freshclam.confのLogTimeをオフにしてログに日付を吐かないようにする。
2.clam-updateスクリプトを修正する。
どう考えても1で解決するべきだねw
どうしても2と言う場合は、下記の様にスクリプトをいじる。
がしかし、なんか/usr/shareの中をいじるのはすごく違和感があるので、/etc/logwatch/scripts/servicesにshareのスクリプトをコピーしてやる。
# cp -a /usr/share/logwatch/scripts/services/clam-update /etc/logwatch/scripts/services/ # vi /etc/logwatch/scripts/services/clam-update
$ThisLine =~ s/ $//; # 107行目 $ThisLine =~ s/^[^>]+>\s+//; #←を追加 ※substr($ThisLine, 28)でも良さそう。
あとは確認して完了
# logwatch --service clam-update
--------------------- clam-update Begin ------------------------ Last ClamAV update process started at Thu May 19 23:43:06 2011 Last Status: main.cvd is up to date (version: 53, sigs: 846214, f-level: 53, builder: sven) daily.cld is up to date (version: 13092, sigs: 118679, f-level: 60, builder: ccordes) bytecode.cvd is up to date (version: 143, sigs: 40, f-level: 60, builder: edwin) Received signal: wake up ---------------------- clam-update End -------------------------