Author Topic: CPU 100% clamd  (Read 60721 times)

0 Members and 2 Guests are viewing this topic.

Offline
***
Re: CPU 100% clamd
« Reply #30 on: October 01, 2020, 03:18:59 PM »
???

Offline
***
Re: CPU 100% clamd
« Reply #31 on: October 10, 2020, 11:36:28 AM »
Pls, help...?!?

Offline
*
Re: CPU 100% clamd
« Reply #32 on: October 11, 2020, 01:23:37 AM »
run this in your /scripts directory,

its a known issue.

sh ./clamd_fix_100_cpu_usage

X

Offline
***
Re: CPU 100% clamd
« Reply #33 on: October 11, 2020, 08:20:32 AM »
Hi,


I read somewhere that after the execution of the command sh ./clamd_fix_100_cpu_usage and when the system is restarted, the problem is restored ...?!?

Thanks in advance!

BR
Venty


Offline
*
Re: CPU 100% clamd
« Reply #34 on: November 10, 2020, 02:34:29 AM »
Edit /usr/lib/systemd/system/clamd.service

Code: [Select]
[Unit]
Description = clamd scanner (%i) daemon
Documentation=man:clamd(8) man:clamd.conf(5) https://www.clamav.net/documents/
After = syslog.target nss-lookup.target network.target

[Service]
Type = simple
ExecStart = /usr/sbin/clamd -c /etc/clamd.d/amavisd.conf --foreground=yes
# Reload the database
ExecReload = /bin/kill -USR2 $MAINPID
Restart = on-failure
TimeoutStartSec = 420
IOSchedulingPriority = 7
CPUSchedulingPolicy = 5
MemoryLimit = 768M
CPUQuota = 25%
Nice = 19

[Install]
WantedBy = multi-user.target

Code: [Select]
systemctl daemon-reload
systemctl restart clamd

I had the same problem, only this solution solved it for me. Now calmd runs with MAX 512M and taking 50% of 1 of 2 cores, so server is running smoothly. Thank you cynique!

Offline
*****
Re: CPU 100% clamd
« Reply #35 on: November 10, 2020, 09:37:12 AM »
Edit /usr/lib/systemd/system/clamd.service

Code: [Select]
[Unit]
Description = clamd scanner (%i) daemon
Documentation=man:clamd(8) man:clamd.conf(5) https://www.clamav.net/documents/
After = syslog.target nss-lookup.target network.target

[Service]
Type = simple
ExecStart = /usr/sbin/clamd -c /etc/clamd.d/amavisd.conf --foreground=yes
# Reload the database
ExecReload = /bin/kill -USR2 $MAINPID
Restart = on-failure
TimeoutStartSec = 420
IOSchedulingPriority = 7
CPUSchedulingPolicy = 5
MemoryLimit = 768M
CPUQuota = 25%
Nice = 19

[Install]
WantedBy = multi-user.target

Code: [Select]
systemctl daemon-reload
systemctl restart clamd

I had the same problem, only this solution solved it for me. Now calmd runs with MAX 512M and taking 50% of 1 of 2 cores, so server is running smoothly. Thank you cynique!

swap/disk usage will be increased if you've it.

Re: CPU 100% clamd
« Reply #36 on: November 10, 2020, 03:17:13 PM »
Thank you cynique!
You are very welcome.

Let's see: unstable/unusable server or correctly uses swap where required. hmmm.  ::)

Offline
*
Re: CPU 100% clamd
« Reply #37 on: November 10, 2020, 06:29:25 PM »
swap/disk usage will be increased if you've it.

Do you know a better solution for this when the FIX script provided by CWP doesn't work? I'll appreciate that!
« Last Edit: November 10, 2020, 06:58:59 PM by Zeticloud Services »

Offline
*
Re: CPU 100% clamd
« Reply #38 on: November 10, 2020, 06:39:52 PM »
Let's see: unstable/unusable server or correctly uses swap where required. hmmm.  ::)

My file is like this, running like a charm:
24789 amavis    39  19  398716 261180   2968 R  12.5 25.7   0:07.05 clamd

My server:
CPU Details: 2 Core (2600 MHz)
RAM: 1Gb    SWAP: 512Mb
Distro Name: CentOS Linux release 7.8.2003 (Core)
Kernel Version: 3.10.0-1127.19.1.el7.x86_64

Code: [Select]
[Unit]
Description = clamd scanner (%i) daemon
Documentation=man:clamd(8) man:clamd.conf(5) https://www.clamav.net/documents/
After = syslog.target nss-lookup.target network.target

[Service]
Type = simple
ExecStart = /usr/sbin/clamd -c /etc/clamd.d/amavisd.conf --foreground=yes
# Reload the database
ExecReload=/bin/kill -USR2 $MAINPID
Restart = on-failure
TimeoutStartSec=420
IOSchedulingPriority = 7
CPUSchedulingPolicy = 5
MemoryLimit = 256M
CPUQuota = 13%
Nice = 19

[Install]
WantedBy = multi-user.target
« Last Edit: November 10, 2020, 06:55:47 PM by Zeticloud Services »

Re: CPU 100% clamd
« Reply #39 on: November 10, 2020, 06:44:17 PM »
You should wrap the above in CODE tags. ;)
Note that I tested quite extensively and if you drop values too low, they simply get ignored.
512M/25% seemed to be a good balance, for most 'lower-end' server/VPS specifications.
« Last Edit: November 10, 2020, 06:46:06 PM by cynique »

Offline
*
Re: CPU 100% clamd
« Reply #40 on: November 10, 2020, 06:52:43 PM »
You should wrap the above in CODE tags. ;)

DONE!

Note that I tested quite extensively and if you drop values too low, they simply get ignored.
512M/25% seemed to be a good balance, for most 'lower-end' server/VPS specifications.

Thanks for the update. For now, seems like it's working fine like that, but I'll keep an eye on it!

Offline
***
Re: CPU 100% clamd
« Reply #41 on: December 13, 2020, 04:44:32 PM »
Hi,

again, today I updated the clam and regarding the same problem...

Pls, help...

thanks in advance!

BR
Venty

Offline
*
Re: CPU 100% clamd
« Reply #42 on: September 19, 2021, 07:26:07 AM »
gerasandor method and clamd_fix_100_cpu_usage does not work for me. anyone have another solution?

Offline
****
Re: CPU 100% clamd
« Reply #43 on: September 19, 2021, 09:09:47 AM »
gerasandor method and clamd_fix_100_cpu_usage does not work for me. anyone have another solution?

Run the fix in the /scripts directory, and then log into the admin panel and manually STOP ClamAV & AMaViS.

After CPU goes down to 0%, Start Just ClamAV, wait for it to run a quick scan, it should go back to 0, then Start AMaViS.

You should be good to go.

Had the same problem, and this worked.

Offline
*
Re: CPU 100% clamd
« Reply #44 on: January 06, 2022, 09:47:28 AM »
I have faced the same issue yesterday with my server...

My server details:

CPU Model: Intel Xeon Processor (Skylake, IBRS)
CPU Details: 1 Core (2100 MHz)
Distro Name: CentOS Linux release 7.9.2009 (Core)
Kernel Version: 3.10.0-1160.49.1.el7.x86_64
Memory: 2GB

The only solution that made my server go back again and work normally with ClamAV and AmAvis up and running was to create a swap image. I add a 4GB swap image and after a server reboot, both ClamAV and AmAvis started normally and did not take CPU time abnormally.

Here is a tutorial on how to create a swap image on Centos 7 CWP -> https://www.mysterydata.com/create-and-add-swap-on-linux-os-cwp-centos-webpanel-and-vesta-cp/

The main problem that I have faced is that AmAvis could not find a socket and connect to ClamAV. This is an error I found in maillog: "host amavis[1975]: (01975-01) (!)connect to /run/clamd.amavisd/clamd.sock failed, attempt #1: Can't connect to a UNIX socket /run/clamd.amavisd/clamd.sock: No such file or directory"

The clamd.sock file was not created after restarting ClamAV service or server reboot. After swap image creating and activating, that file was created automatically when I start the ClamAV service.

Hope that this would help someone with the same issue.