CPU 100% clamd

Started by petrosvel, January 22, 2018, 04:25:33 PM

Previous topic - Next topic

venty


venty


x1705

run this in your /scripts directory,

its a known issue.

sh ./clamd_fix_100_cpu_usage

X

venty

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


Zeticloud Services

Quote from: cynique on May 07, 2020, 09:57:41 PM
Edit /usr/lib/systemd/system/clamd.service


[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


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!

Sandeep

Quote from: Zeticloud Services on November 10, 2020, 02:34:29 AM
Quote from: cynique on May 07, 2020, 09:57:41 PM
Edit /usr/lib/systemd/system/clamd.service


[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


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.

cinique

Quote from: Zeticloud Services on November 10, 2020, 02:34:29 AM
Thank you cynique!
You are very welcome.

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

Zeticloud Services

#37
Quote from: Sandeep on November 10, 2020, 09:37:12 AM
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!

Zeticloud Services

#38
Quote from: cynique on November 10, 2020, 03:17:13 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


[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

cinique

#39
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.

Zeticloud Services

Quote from: cynique on November 10, 2020, 06:44:17 PM
You should wrap the above in CODE tags. ;)

DONE!

Quote from: cynique on November 10, 2020, 06:44:17 PM
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!

venty

Hi,

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

Pls, help...

thanks in advance!

BR
Venty

dragonvid

gerasandor method and clamd_fix_100_cpu_usage does not work for me. anyone have another solution?

Starburst

Quote from: dragonvid 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?

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.

vradova

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.