In this post I will show how to quickly do the basic analysis of an Ubuntu system. Some commands run on other distribustions
First check Your server by top or htop. Second comand is more usefull. The Windows users may notice similarities to Task Manager. In above picture You can see the two processes:
Mysqld
php-fpm
Next check Your CPU. The command mpstat -P ALL 1 is used to monitor CPU usage. It displays statistics for all available processors (including the overall processor), refreshing the data every 1 second. In above example we can see the highest usage is shown by cores 0, 1, and 15. Core 15 is the most loaded and requires balancing. Cores 6 and 11 have the highest idle time, meaning they are the least loaded. Solution: Analyze CPU15, optimize load distribution at the application level, and redirect processes to other cores.
By the command free -mYou can check the physical memory. Look on above stats:
Physical memory (RAM): 32,177 MB – Total amount of available RAM.
used: 24,525 MB – Amount of memory currently used by the system and applications.
free: 254 MB – Amount of physical memory that is currently free.
shared: 212 MB – Amount of memory shared between processes.
buff/cache: 7,398 MB – Amount of memory used by buffers and cache. This memory can be quickly freed if the system needs it.
available: 6,980 MB – Amount of memory available for new processes, without the need to free memory from buffers.
Swap:
total: 30,516 MB – Total amount of available swap memory.
used: 15,260 MB – Amount of swap memory that is currently used.
free: 15,256 MB – Amount of available swap memory.
Recomendation: Physical memory usage is high, averaging 76%, with only 254 MB free. However, the server still has a buffer of 7,398 MB and available reserve memory of 6,980 MB. The server is actively using swap memory – 15,260 MB (about 50%). The first step should be to consider increasing the physical RAM if the device allows it. The next step is to analyze the applications that use RAM and reduce the use of buffers
Applications stats: best way is, use the commands ps aux —sort=-%mem | head -10 and ps aux —sort=-%cpu | head -10. This command can show to the admin which process take too much RAM or CPU. In above picture You can see:
MySQL (mysqld): 76,2% CPU oraz 59,1 % RAM
Appache (httpd): 20,2% CPU 0,1% RAM
Ffmpeg (kamery): 14,9% CPU, 1,4% RAM
ClamAV (clamd): 0,0% CPU, 4,2% RAM
Wrapping up this post. These are just some of the basic commands for server analysis. They help me analyze devices for clients who haven’t implemented Nagios or Zabbix.