Essential System Monitoring Tools in CentOS 7

In this tutorial, we are going to show you how to use basic system monitoring tools on a Linux VPS running CentOS 7 as the operating system.

Determining what processes are running, the amount of free memory on your system, and the storage space for the SSD available for use is critical when setting up your system. One of the main system monitoring tools that is available on all Linux systems is ps… Command ps will show a snapshot of the current processes running on the CentOS VPS and will display information about the selection of active processes. Command ps has many different options that can be mixed. In many situations, ps aux will provide you with all the information you need.

ps aux

The output of the command will provide you with information such as the owner of the process, the ID of the process using, cpu and memory, the date and time the process was started, etc. The output should be similar to the one below:

# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  2.0  59808 20668 ?        Ss   Oct09   3:59 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
root         2  0.0  0.0      0     0 ?        S    Oct09   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Oct09   0:10 [ksoftirqd/0]
root         7  0.0  0.0      0     0 ?        S    Oct09   0:02 [migration/0]
root         8  0.0  0.0      0     0 ?        S    Oct09   0:00 [rcu_bh]
root         9  0.0  0.0      0     0 ?        S    Oct09   0:00 [rcuob/0]
root        10  0.0  0.0      0     0 ?        S    Oct09   0:00 [rcuob/1]
root        11  0.0  0.0      0     0 ?        R    Oct09   7:00 [rcu_sched]
root        12  0.0  0.0      0     0 ?        S    Oct09  12:13 [rcuos/0]
root        13  0.0  0.0      0     0 ?        S    Oct09   5:39 [rcuos/1]
...

More use cases and options visit the page man:

man ps

The next useful tool for system monitoring top… Similarly ps, top displays Linux processes running on the server in real time, but the output is dynamic. Run top to check the output:

# top
top - 09:01:41 up 8 min,  0 users,  load average: 0.00, 0.00, 0.00
Tasks:  32 total,   1 running,  31 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.2 us,  0.0 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1572864 total,  1318572 free,    28772 used,   225520 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  1331552 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
  728 root      20   0  155104   2244   1340 R   0.2  0.2   0:00.15 top
    1 root      20   0   41120   3260   2376 S   0.0  0.1   0:00.15 systemd
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd
    3 root      20   0       0      0      0 S   0.0  0.0   0:00.00 khelper
   65 root      20   0   36168   1220   1440 S   0.0  0.1   0:00.03 systemd-journal
   74 root      20   0   41100   1200   1572 S   0.0  0.1   0:00.00 systemd-udevd
  105 root      20   0   24124   1240   1692 S   0.0  0.1   0:00.00 systemd-logind
  108 root      20   0  293112   2208   2408 S   0.0  0.1   0:00.00 rsyslogd

To end the utility, enter q… To sort the list by memory or CPU usage, enter or respectively. man page top will provide you with additional information on their use.

man top

To determine memory usage, run the following command:

free -m

The free command will display the amount of free and used memory on the system in megabytes. It will give you information about total memory, memory in use, free, total, cached and available. The free command will give you information about the swap file too.

# free -m
              total        used        free      shared  buff/cache   available
Mem:            992         237         256           9         498         551
Swap:          2047         298        1749

Visit the page for more details and options:

man free

Next, the df command will display a report on the file system disk space usage. To view the information in a human-friendly form, run the following command:

df -h

The output should look like below:

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        20G   17G  3.4G  83% /
devtmpfs        487M     0  487M   0% /dev
tmpfs           497M     0  497M   0% /dev/shm
tmpfs           497M   65M  432M  14% /run
tmpfs           497M     0  497M   0% /sys/fs/cgroup
/dev/sda1       240M  111M  113M  50% /boot
tmpfs           100M     0  100M   0% /run/user/0
tmpfs           100M     0  100M   0% /run/user/501

The man page will give you more information on how to use them.

man df

The last tool we will write about is du… This command will display the space usage score of the file. For example, to display the total space usage in the / home directory, you can use the following command:

du -sxch /home/

Output example:

# du -sxch /home/
391M    /home/
391M    total

To learn more about the du command and other use cases, visit man:

man du

PS … If you liked this post, please share it with your friends on social networks using the buttons on the left side of the post, or just leave a comment below. Thank you in advance.

Sidebar