1. Store
  2. Apps
  3. Hardware
  4. Support
  5. Solutions

ClearFoundation

Forums
Welcome, Guest
Trick : how to limit CPU and I/O load with clamav
(1 viewing) 1 Guest
Go to bottomPage: 1
TOPIC: Trick : how to limit CPU and I/O load with clamav
*
#37119
Trick : how to limit CPU and I/O load with clamav 1 Year, 3 Months ago  
For those wanting to limit CPU load and/or IO load when running clamav ; I suppose it is already known by a few (if not everyone) but it may still help some...

On ClearOS, Clamav scanning is scheduled by /etc/cron.d/app-antivirus.
Code:

0 2 * * * root /var/webconfig/scripts/avscan.php >/dev/null 2>&1


In this case, clamscan is called by the php script everyday at 02:00.

/var/webconfig/scripts/avscan.ph is calling /var/webconfig/scripts/avscan.inc.php. The simple trick to limit CPU and I/O load is then to edit the script /var/webconfig/scripts/avscan.inc.php and replace the line :
Code:

define('AVSCAN_SCANNER', '/usr/bin/clamscan');


by the following one :
Code:

define('AVSCAN_SCANNER', 'ionice -c3 nice -n 19 /usr/bin/clamscan');



ionice will limit the I/O exchange (idle mode ; please have a look at the man page)
nice will specify a low nice for clamscan (19 rather than 0 which is the default ; please have a look at the man page)

For the ones running their own backups (rsync, rsnapshot, ...), it make sense to ionice and nice these processes too...

Regards,

Xavier.
Piwick
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#43190
Re:Trick : how to limit CPU and I/O load with clamav 10 Months, 3 Weeks ago  
Well I didnt know, so thank you very much.

Found this after finding my server very slow http response through it, its only an Atom 330 and otherwise copes well but the clam io seems to be the one that maxes it out when checked in top, ie sustained 99%

I have a low use low user system, would there be any benefit or detrament in using c2 instead?

Also due to low use generally would an n value closer to 0 be ok?

So basically for ionice -c :

The scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.

Idle
A program running with idle io priority will only get disk time when no other program has asked for disk io for a defined grace period. The impact of idle io processes on normal system activity should be zero. This scheduling class does not take a priority argument. Presently, this scheduling class is permitted for an ordinary user (since kernel 2.6.25).

Best effort
This is the effective scheduling class for any process that has not asked for a specific io priority. This class takes a priority argument from 0-7, with lower number being higher priority. Programs running at the same best effort priority are served in a round-robin fashion.

Note that before kernel 2.6.26 a process that has not asked for an io priority formally uses "none" as scheduling class, but the io scheduler will treat such processes as if it were in the best effort class. The priority within the best effort class will be dynamically derived from the cpu nice level of the process: io_priority = (cpu_nice + 20) / 5.

For kernels after 2.6.26 with CFQ io scheduler a process that has not asked for an io priority inherits CPU scheduling class. The io priority is derived from the cpu nice level of the process (same as before kernel 2.6.26).

Real time
The RT scheduling class is given first access to the disk, regardless of what else is going on in the system. Thus the RT class needs to be used with some care, as it can starve other processes. As with the best effort class, 8 priority levels are defined denoting how big a time slice a given process will receive on each scheduling window. This scheduling class is not permitted for an ordinary (i.e., non-root) user.


and for nice -n :

The nice levels go from -20 to 19.

-20 is the lowest nice level, which gives it the highest priority. 19 is the highest nice level, which gives it the lowest priority. Just think of the nice level as "The ability of the program to play nice with other programs." The higher the nice level, the more the program will get out of the way of other programs. The lower the nice level, the more it will stop other programs from using system resources.
Duncan
Gold Boarder
Posts: 202
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2012/07/02 05:58 By Mindriot.
The administrator has disabled public write access.
 
#46119
Re:Trick : how to limit CPU and I/O load with clamav 8 Months, 1 Week ago  
Is this applicable to 6.3 as well?

If so where are the files to edit?
Duncan
Gold Boarder
Posts: 202
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1
  get the latest posts directly to your desktop