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 Block Devices and File Systems
16.3.1. Using the lsblk Command
16.3.2. Using the blkid Command
16.3.3. Using the partx Command
16.3.4. Using the findmnt Command
16.3.5. Using the df Command
16.3.6. Using the du Command
16.3.7. Using the System Monitor Tool
16.4. Viewing Hardware Information
16.4.1. Using the lspci Command
16.4.2. Using the lsusb Command
16.4.3. Using the lspcmcia Command
16.4.4. Using the lscpu Command
16.5. Monitoring Performance with Net-SNMP
16.5.1. Installing Net-SNMP
16.5.2. Running the Net-SNMP Daemon
16.5.3. Configuring Net-SNMP
16.5.4. Retrieving Performance Data over SNMP
16.5.5. Extending Net-SNMP
16.6. Additional Resources
16.6.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

To display a list of current system processes, including processes that are owned by other users, run the ps ax command. For example:
~]$ ps ax
  PID TTY      STAT   TIME COMMAND
    1 ?        Ss     0:01 /sbin/init
    2 ?        S      0:00 [kthreadd]
    3 ?        S      0:02 [ksoftirqd/0]
    6 ?        S      0:00 [migration/0]
    7 ?        S      0:00 [watchdog/0]
[output truncated]
To display the owner alongside each process, use the ps aux command:
~]$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.8  58108 25056 ?        Ss   Oct12   0:01 /sbin/init
root         2  0.0  0.0      0     0 ?        S    Oct12   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Oct12   0:02 [ksoftirqd/0]
root         6  0.0  0.0      0     0 ?        S    Oct12   0:00 [migration/0]
root         7  0.0  0.0      0     0 ?        S    Oct12   0:00 [watchdog/0]
[output truncated]
You can also use the ps command in combination with the grep command to see if a particular process is running. For example, to determine if Emacs is running, type:
~]$ ps ax | grep emacs
12056 pts/3    S+     0:00 emacs
12060 pts/2    S+     0:00 grep --color=auto emacs
Note that ps always produces a static list, that is, a snapshot of what was running when you invoked the command. If you want a constantly updated list of running processes, use the top command or the System Monitor application.
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 currently running processes and important information about them including their memory and CPU usage. The list is both real-time and interactive. An example of output from the top command is provided as follows:
~]$ top
top - 18:11:48 up 1 min,  1 user,  load average: 0.68, 0.30, 0.11
Tasks: 122 total,   1 running, 121 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.5%sy,  0.0%ni, 93.4%id,  5.7%wa,  0.2%hi,  0.2%si,  0.0
Mem:    501924k total,   376496k used,   125428k free,    29664k buffers
Swap:  1015800k total,        0k used,  1015800k free,   189008k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1601 root      40   0 20172 1084  920 S  0.3  0.2   0:00.08 hald-addon-sto
 1998 silas     40   0 14984 1160  880 R  0.3  0.2   0:00.13 top
    1 root      40   0 19160 1412 1156 S  0.0  0.3   0:00.96 init
    2 root      40   0     0    0    0 S  0.0  0.0   0:00.01 kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.05 migration/0
    4 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
    6 root      RT   0     0    0    0 S  0.0  0.0   0:00.04 migration/1
    7 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/1
    8 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/1
    9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events/0
   10 root      20   0     0    0    0 S  0.0  0.0   0:00.01 events/1
   11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cpuset
   12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper
[output truncated]
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
Space Immediately refresh the display
h Display a help screen
k Kill a process. You are prompted for the process ID and the signal to send to it.
n Change the number of processes displayed. You are prompted to enter the number.
u Sort by user.
M Sort by memory usage.
P Sort by CPU usage.
q Exit the utility.

16.1.3. Using the System Monitor Tool

If you prefer a graphical interface, you can use the System Monitor tool. To start it, select ApplicationsSystem ToolsSystem Monitor from the Activities menu or type gnome-system-monitor at a shell prompt.
System Monitor - Processes
Processes tab of the gnome-system-monitor
Figure 16.1. System Monitor - Processes

The Processes tab of the System Monitor allows you to search for a process in the list of running processes. Using this application, you can also view all processes, your processes, or active processes.
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.
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.
Note that to sort the information by a specific column, click the name of that column. By default, this sorts the information by the selected column in ascending order. Click the name of the column again to toggle the sort between ascending and descending order.