rankzoqa.blogg.se

Bash script to monitor cpu and memory usage
Bash script to monitor cpu and memory usage








bash script to monitor cpu and memory usage

Tasks: 265 total, 1 running, 263 sleeping, 0 stopped, 1 zombie The header on output has the required information. However it also reports total memory usage and can be used to monitor the total RAM usage. The top command is generally used to check memory and cpu usage per process. The top few lines indicate total memory, free memory etc and so on.

bash script to monitor cpu and memory usage

The vmstat command with the s option, lays out the memory usage statistics much like the proc command. They indicate same values of memory usage as the free command. $ cat /proc/meminfoĬheck the values of MemTotal, MemFree, Buffers, Cached, SwapTotal, SwapFree. They are rather virtual files that contain dynamic information about the kernel and the system. Know that the /proc file system does not contain real files. The next way to check memory usage is to read the /proc/meminfo file. The last line is the swap memory, which in this case is lying entirely free. Linux has the habit of caching lots of things for faster performance, so that memory can be freed and used if needed. This is the free memory in first line added with the buffers and cached amount of memory. The second line tells that 4.6 GB is free. The catch over here is the cached and buffers column. The used column shows the amount of RAM that has been used by linux, in this case around 6.4 GB. The total os 7976 MB is the total amount of RAM installed on the system, that is 8GB. The free command is the most simple and easy to use command to check memory usage on linux. Its just like what happens on your desktop PC.

bash script to monitor cpu and memory usage

If not, the site would become very slow or even go down when there is a traffic spike, simply because memory would fall short. If you are running a webserver, then the server must have enough memory to serve the visitors to the site. It is often important to check memory usage and memory used per process on servers so that resources do not fall short and users are able to access the server.










Bash script to monitor cpu and memory usage