Tools for Regular Operations122
There are simple commands we can use to monitor the most basic use cases, such as the following ones Disk CPU
Memory Network
This includes several ways of monitoring,
such as one-shot monitoring, continuously, or even fora period of time to diagnose performance better.
MemoryMemory can be monitored via the free command. It provides details on how much
random-access memory(
RAM) and swap memory are available and in use, which also indicates how
much memory is used by shares, buffers, or caches.
Linux tends to use all available memory any unused RAM is directed toward caches or buffers and memory pages that are not being used. These are swapped out to disk if available. You can see an example of this here:
# freetotal used free shared buff/cache available
Mem: 823112 484884 44012 2976 294216 Swap 8388604 185856 In the preceding output, we can see that the system has a total of 823
megabytes (
MB) of RAM and that it’s using some swap and some memory for buffers. This system is not swapping heavily as it’s almost idle (well check the load average later in this chapter, so we should not be concerned about it.
When RAM usage gets high and there’s
no more swap available, the kernel includes a protection mechanism called
Out-of-Memory Killer (
OOM Killer). It determines based on time in execution, resource usage, and more—which processes in the system should be terminated to recover the system so that it’s functional. This, however,
comes at a cost, as the kernel knows about the processes that may have gone out of control. However, the killer may kill databases and web servers and leave the system in an unstable state. For production servers, it is sometimes typical—instead of letting the
OOM-Killer start killing processes in an uncontrolled way—to either tune the values for some critical process so that those are not killed or to cause a system crash.
Checking for free resources – memory and disk (free and df A system crash is used to collect debug information that can later be analyzed via a dump containing information about what caused the crash, as well as a memory dump that can be diagnosed.
We will comeback to this topic in Chapter 16, Kernel Tuning and Managing Performance Profiles with tuned. Let’s move on and check the disk space that’s in use.
Disk spaceDisk space can be checked via the df tool. df provides data as output for each filesystem. This indicates
the filesystem and its size, available space, percent of utilization, and mount point.
Let’s check this in our example system, as follows:
Share with your friends: