[未解決] clamscan がCPU100%になる、時間がかかる問題
CentOS 6.x にて 夜中に clamscan がCPU使用率100%近くを使い、monit がアラートを沢山投げてくるので、対策。
対策方法
- /sys 等もscanするので、scan対象から外す。 (→失敗)
- ionice と nice を使って実行優先順位を下げて clamscan を起動する (→失敗)
- cpulimit を使ってCPU使用率を下げる (→失敗)
- clamscan の前に monit unmonitor all して、後に monit monitor all する (→ダメっぽい)
- tripwire の前後に monit unmonitor (→実施中)
次にやろうかと思っていること
- tripwire を捨てて、inotify とか別のものを使う
現状、対策方法わからず困っているところ。
scan対象から外す場合
/etc/clamd.conf を使っている場合
下記参考URLでは、この設定ファイルは使われていないので、起動コマンドを使えと書いてある
ExcludePath ^/proc/
ExcludePath ^/sys/
ExcludePath ^/dev/
起動コマンドの場合
clamscan -ir --exclude-dir=^/sys --exclude-dir=^/dev
- exclude-dir=^/proc --detect-pua=yes --scan-mail=no --max-filesize=5M
- log=/var/log/clamav/scanlog.log
起動スクリプトの場合: 「CentOSで自宅サーバー構築」の場合
アンチウィルスソフト導入(Clam AntiVirus) - CentOSで自宅サーバー構築
centossrv.com/clamav.shtml
スクリプトを書いて保存して、clamscan.exclude というファイルに記述する
参考URL
Clamscan scanning /sys despite clamd.conf entry | ClamAV | users
http://www.gossamer-threads.com/lists/clamav/users/48832
ionice / nice を使う場合
/etc/cron.daily/virusscan の clamscan を ionice / nice する
ionice -c3 nice -n 19 /usr/bin/clamscan --recursive --remove ${excludeopt} / > $CLAMSCANTMP 2>&1
それでも CPU 使用率が高い...
cpulimit を使う
- yum install cpulimit
実行後に cpulimit を実行して CPU使用率を30%にする
ionice -c3 nice -n 19 /usr/bin/clamscan --recursive --remove ${excludeopt} / > $CLAMSCANTMP 2>&1
/usr/bin/cpulimit --exe clamscan --limit 30
以下のような 起動時にCPU使用率を指定するのは、開発バージョンのみらしい
cpulimit --limit 40 /etc/rc.d/rc.boinc start
参考URL
- software recommendation - Can I limit the CPU usage of a single application? - Ask Ubuntu
http://askubuntu.com/questions/21056/can-i-limit-the-cpu-usage-of-a-single-application
- CPU limit
http://cpulimit.sourceforge.net/
search words
cpu usage clamscan clamd