Paper Lantern for cPanel accounts is being retired this year. Find out more »
cPanel & WHM Version 102 has been released, and brings a slew of great updates. Take a look at what is included, and then upgrade today!

Have ClamScan route through cpuwatch

cPanelPeter shared this idea 4 years ago
Open Discussion

As a System Administrator, I would like to see an option within the ClamScan configuration section (of WHM Plugins) to allow the scan all users option to go through cpuwatch. This provides a benefit of keeping the servers load in check. If the scan starts to consume more CPU processing than available, cpuwatch will simply stop the scan until the load average comes down again.

We have in our documentation a method that system administrators can use by adding a cron job to scan all users. This can be expanded upon to include cpuwatch within the command called via cron.

CPUS=$(grep -c 'model name' /proc/cpuinfo) ; EXCPUS=$(grep extracpus

/var/cpanel/cpanel.config | cut -d = -f2) ; TOTCPUS=$(($CPUS + $EXCPUS))

; while read domain user ; do /usr/local/cpanel/bin/cpuwatch ${TOTCPUS}

/usr/local/cpanel/3rdparty/bin/clamscan -i -r /home/"$user" 2>&1; done

</etc/trueuserdomains >>/root/infections.txt

This will SIGSTOP the scanning if the load goes above the cpuwatch threshold. And will resume when load drops below the cpuwatch threshold. After running the above, you can check the /root/infections.txt file and you will see:

----------- SCAN SUMMARY -----------

Known viruses: 6587818

Engine version: 0.99.4

Scanned directories: 44

Scanned files: 17

Infected files: 0

Data scanned: 0.26 MB

Data read: 1.65 MB (ratio 0.16:1)

Time: 19.178 sec (0 m 19 s)

cpuwatch (Fri Jul 13 15:03:43 2018): System load is currently 1.07;

waiting for it to go down below 1.00 to continue …

cpuwatch (Fri Jul 13 15:04:14 2018): System load is currently 0.65,

which is below the threshold of 1.00. Continuing …

Leave a Comment
Attach a file