Here is the list of commands that can be used to check memory usage in Linux.
You can use the grep command to search all log files in /var/log/ location for an out-of-memory error.
grep -i -r 'out of memory' /var/log/
2) free -m
You can use the command “free” to find the current memory usage in the server.
The command will show you the current RAM and swap usages in MB.
The history of memory usage for the day can be found using the “sar” command.
4) top -c
Another tool to identify the Memory consuming processes is the “top” command, which will give you the option to sort the running processes based on their resource usage.
For a cPanel server, you can use the grep command to search the website access logs to see any suspicious/abusive access to the website to cause this resource exhaustion.
Example: grep -ir “05/Jul/2022:10:20” /usr/local/apache/domlogs/
Some suspicious activities identifiable from the access logs are
High access from specific IP addresses.
High access to unavailable resources/files etc.
High number of HTTP POST requests.
High number of failed access attempts like login.
Use the command mysqladmin proc stat to identify any MySQL queries hanging for a long time to cause a high memory usage for them.
mysqladmin proc stat