Product SiteDocumentation Site

Chapter 16. System Monitoring Tools

16.1. Viewing System Processes
16.1.1. Using the ps Command
16.1.2. Using the top Command
16.1.3. Using the System Monitor Tool
16.2. Viewing Memory Usage
16.2.1. Using the free Command
16.2.2. Using the System Monitor Tool
16.3. Viewing CPU Usage
16.3.1. Using the System Monitor Tool
16.4. Viewing Block Devices and File Systems
16.4.1. Using the lsblk Command
16.4.2. Using the blkid Command
16.4.3. Using the partx Command
16.4.4. Using the findmnt Command
16.4.5. Using the df Command
16.4.6. Using the du Command
16.4.7. Using the System Monitor Tool
16.5. Viewing Hardware Information
16.5.1. Using the lspci Command
16.5.2. Using the lsusb Command
16.5.3. Using the lspcmcia Command
16.5.4. Using the lscpu Command
16.6. Monitoring Performance with Net-SNMP
16.6.1. Installing Net-SNMP
16.6.2. Running the Net-SNMP Daemon
16.6.3. Configuring Net-SNMP
16.6.4. Retrieving Performance Data over SNMP
16.6.5. Extending Net-SNMP
16.7. Additional Resources
16.7.1. Installed Documentation
In order to configure the system, system administrators often need to determine the amount of free memory, how much free disk space is available, how the hard drive is partitioned, or what processes are running.

16.1. Viewing System Processes

16.1.1. Using the ps Command

The ps command allows you to display information about running processes. It produces a static list, that is, a snapshot of what is running when you execute the command. If you want a constantly updated list of running processes, use the top command or the System Monitor application instead.
To list all processes that are currently running on the system including processes owned by other users, type the following at a shell prompt:
ps ax
For each listed process, the ps ax command displays the process ID (PID), the terminal that is associated with it (TTY), the current status (STAT), the cumulated CPU time (TIME), and the name of the executable file (COMMAND). For example:
~]$ ps ax
  PID TTY      STAT   TIME COMMAND
    1 ?        Ss     0:02 /usr/lib/systemd/systemd --system --deserialize 20
    2 ?        S      0:00 [kthreadd]
    3 ?        S      0:00 [ksoftirqd/0]
    5 ?        S      0:00 [kworker/u:0]
    6 ?        S      0:00 [migration/0]
[output truncated]
To display the owner alongside each process, use the following command:
ps aux
Apart from the information provided by the ps ax command, ps aux displays the effective username of the process owner (USER), the percentage of the CPU (%CPU) and memory (%MEM) usage, the virtual memory size in kilobytes (VSZ), the non-swapped physical memory size in kilobytes (RSS), and the time or date the process was started. For instance:
~]$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.3  53128  2988 ?        Ss   13:28   0:02 /usr/lib/systemd/systemd --system --deserialize 20
root         2  0.0  0.0      0     0 ?        S    13:28   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    13:28   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S    13:28   0:00 [kworker/u:0]
root         6  0.0  0.0      0     0 ?        S    13:28   0:00 [migration/0]
[output truncated]
You can also use the ps command in a combination with grep to see if a particular process is running. For example, to determine if Emacs is running, type:
~]$ ps ax | grep emacs
 2625 ?        Sl     0:00 emacs
For a complete list of available command line options, refer to the ps(1) manual page.

16.1.2. Using the top Command

The top command displays a real-time list of processes that are running on the system. It also displays additional information about the system uptime, current CPU and memory usage, or total number of running processes, and allows you to perform actions such as sorting the list or killing a process.
To run the top command, type the following at a shell prompt:
top
For each listed process, the top command displays the process ID (PID), the effective username of the process owner (USER), the priority (PR), the nice value (NI), the amount of virtual memory the process uses (VIRT), the amount of non-swapped physical memory the process uses (RES), the amount of shared memory the process uses (SHR), the percentage of the CPU (%CPU) and memory (%MEM) usage, the cumulated CPU time (TIME+), and the name of the executable file (COMMAND). For example:
~]$ top
top - 19:22:08 up  5:53,  3 users,  load average: 1.08, 1.03, 0.82
Tasks: 117 total,   2 running, 115 sleeping,   0 stopped,   0 zombie
Cpu(s):  9.3%us,  1.3%sy,  0.0%ni, 85.1%id,  0.0%wa,  1.7%hi,  0.0%si,  2.6%st
Mem:    761956k total,   617256k used,   144700k free,    24356k buffers
Swap:  1540092k total,    55780k used,  1484312k free,   256408k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  510 john      20   0 1435m  99m  18m S  9.0 13.3   3:30.52 gnome-shell
32686 root      20   0  156m  27m 3628 R  2.0  3.7   0:48.69 Xorg
 2625 john      20   0  488m  27m  14m S  0.3  3.7   0:00.70 emacs
    1 root      20   0 53128 2640 1152 S  0.0  0.3   0:02.83 systemd
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.01 kthreadd
    3 root      20   0     0    0    0 S  0.0  0.0   0:00.18 ksoftirqd/0
    5 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kworker/u:0
    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    7 root      RT   0     0    0    0 S  0.0  0.0   0:00.30 watchdog/0
    8 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 cpuset
    9 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 khelper
   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kdevtmpfs
   11 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 netns
   12 root      20   0     0    0    0 S  0.0  0.0   0:00.11 sync_supers
   13 root      20   0     0    0    0 S  0.0  0.0   0:00.00 bdi-default
   14 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kintegrityd
   15 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kblockd
Table 16.1, “Interactive top commands” contains useful interactive commands that you can use with top. For more information, refer to the top(1) manual page.

Table 16.1. Interactive top commands

Command Description
Enter, Space Immediately refreshes the display.
h, ? Displays a help screen.
k Kills a process. You are prompted for the process ID and the signal to send to it.
n Changes the number of displayed processes. You are prompted to enter the number.
u Sorts the list by user.
M Sorts the list by memory usage.
P Sorts the list by CPU usage.
q Terminates the utility and returns to the shell prompt.

16.1.3. Using the System Monitor Tool

The Processes tab of the System Monitor tool allows you to view, search for, change the priority of, and kill processes from the graphical user interface.
To start the System Monitor tool, either select ApplicationsSystem ToolsSystem Monitor from the Activities menu, or type gnome-system-monitor at a shell prompt. Then click the Processes tab to view the list of running processes.
System Monitor — Processes

Figure 16.1. System Monitor — Processes

For each listed process, the System Monitor tool displays its name (Process Name), current status (Status), percentage of the memory usage (% CPU), nice value (Nice), process ID (ID), memory usage (Memory), the channel the process is waiting in (Waiting Channel), and additional details about the session (Session). To sort the information by a specific column in ascending order, click the name of that column. Click the name of the column again to toggle the sort between ascending and descending order.
By default, the System Monitor tool displays a list of processes that are owned by the current user. Selecting various options from the View menu allows you to:
  • view only active processes,
  • view all processes,
  • view your processes,
  • view process dependencies,
  • view a memory map of a selected process,
  • view the files opened by a selected process, and
  • refresh the list of processes.
Additionally, various options in the Edit menu allows you to:
  • stop a process,
  • continue running a stopped process,
  • end a process,
  • kill a process,
  • change the priority of a selected process, and
  • edit the System Monitor preferences, such as the refresh interval for the list of processes, or what information to show.
You can also end a process by selecting it from the list and clicking the End Process button.