Search code examples
securitycentosvps

CPU and RAM running randomly when no app is running?


Is it a normal thing to have random bursts of CPU usage going to 100% for a few seconds and RAM usage also keeps changing on its own even when my app is not running on my VPS server and no client is active either? It does have a Apache http server running but I never use it. My usage is for a Java application only but that also was not running during this time. I have a domain name and an SSL certificate, not sure whether that is causing this? I am worried that some hacker has put a malware in my VPS running on CentOS 7. How am I supposed to check what is the reason for these bursts of computation. These correspond with network I/O as well but that is in kiloBytes.

enter image description here


Solution

  • You could use htop or similar and it could show you what is using those cpu resources at the times when the spikes occur.

    If you dont have htop you can install it with sudo yum install htop . However note that htop is only showing you what is happening at that time, i.e. a real time view.

    However there is also atop. One of the main benefits of atop over tools like top and htop is its ability to log system and process information over time. This can be helpful for diagnosing issues that only occur intermittently or for a short period of time which sounds exactly like the thing you need for issues you are having.

    You can install atop with sudo yum install atop . You can start the atop process and logging with:

    sudo systemctl start atop
    sudo systemctl enable atop
    

    To view system resources in real-time, you can just run atop. To view the logs, you can use atop -r, followed by the log file's path. By default, atop logs are stored in /var/log/atop/ .