Basic system monitoring tools in CentOS 7

Basic system monitoring tools in CentOS 7

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

Determining which processes are running, the amount of free memory on your system as well as the free SSD storage available to use is crucial when configuring the system. One of the basic system monitoring tools which is available on all Linux systems is ps. The ps command will report a snapshot of the current processes running on your CentOS VPS and will display information about a selection of active processes. The ps command has many different options which 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 process owner, ID of the process, CPU and memory usage, the time or date when 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.5  0.2  41220  3660 ?        Ss   08:53   0:00 init -z
root         2  0.0  0.0      0     0 ?        S    08:53   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    08:53   0:00 [khelper]
root        65  0.0  0.1  36768  1820 ?        Ss   08:53   0:00 /usr/lib/systemd/systemd-journald
root        73  0.0  0.1  41600  1700 ?        Ss   08:53   0:00 /usr/lib/systemd/systemd-udevd
root       103  0.0  0.0  24224  1536 ?        Ss   08:53   0:00 /usr/lib/systemd/systemd-logind
root       109  0.0  0.1 293512  2608 ?        Ssl  08:53   0:00 /usr/sbin/rsyslogd -n
dbus       112  0.0  0.1  26548  1680 ?        Ss   08:53   0:00 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root       137  0.0  0.2  82504  3576 ?        Ss   08:53   0:00 /usr/sbin/sshd -D
...

For more usage examples and options visit the man page:

# man ps

The next useful tool for system monitoring is top. Similarly to ps, top displays the Linux processes running on your 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
  718 root      20   0  155404   2144   1540 R   0.3  0.1   0:00.05 top
    1 root      20   0   41220   3660   2276 S   0.0  0.2   0:00.25 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   36768   1820   1540 S   0.0  0.1   0:00.02 systemd-journal
   73 root      20   0   41600   1700   1272 S   0.0  0.1   0:00.00 systemd-udevd
  103 root      20   0   24224   1540   1292 S   0.0  0.1   0:00.00 systemd-logind
  109 root      20   0  293512   2608   2008 S   0.0  0.2   0:00.00 rsyslogd

To terminate the utility, enter q. To sort the list by memory or CPU usage, enter M or P respectively. The man page of top will provide you with additional information about the usage.

# man top

To determine the memory usage, run the following command:

# free -m

The free command will display amount of free and used memory in the system in megabytes. It will provide you with information about the total amount of memory, the amount of memory which is used, free, shared, cached and available. The free command will provide you with information about the swap space too.

# free -m
              total        used        free      shared  buff/cache   available
Mem:           1536          31        1282         136         221        1296
Swap:             0           0           0

Visit the man page for more information and usage options:

# man free

Next, the df command will display a report of the file system disk space usage. To view the information in human readable format, run:

# df -h

The output should look like the one below:

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/simfs       30G  1.9G   29G   7% /
devtmpfs        768M     0  768M   0% /dev
tmpfs           768M     0  768M   0% /dev/shm
tmpfs           768M  8.1M  760M   2% /run
tmpfs           768M     0  768M   0% /sys/fs/cgroup

The man page will provide you with additional information about the usage.

# man df

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

# du -sxch /home/

Sample output:

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

To learn more about the du command and the other usage options, visit the man page:

# man du

Of course you don’t have to do any of this if you use one of our CentOS 7 VPS hosting services, in which case you can simply ask our expert Linux admins to help you determine the resource usage on your server. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment