[EdCert previous] [EdCert next] [EdCert top]

Monitoring CPU Performance

The general usage of a system can be determined with the uptime command. Systems which use TCP/IP have a related tool, ruptime which allows this information to be gathered remotely. Uptime also displays the current time, the amount of time that has passed since the last system reboot, the number of current users, and the average number of jobs in the run queue in the last one, five, and fifteen minutes. The load average is calculated by the kernel which samples the number of processes waiting to execute.

A sample output of the uptime command is shown below.

10:36am  up 11 days, 21:19,  5 users,  load average: 0.01, 0.05, 0.00

If a system shows a load above average the process status command, ps, will provides information about every processes currently running on the system so that the process or processes creating the workload can be determined.

Information displayed by the ps command includes:

With the command options, ps -el, additional information about each process can be displayed. Included are the state, nice value, memory or disk address, priority, and size, in most commonly 4096 byte blocks, of the process. Here is a sample output.
 F S   UID   PID  PPID  C PRI NI     ADDR     SZ    WCHAN TTY      TIME CMD
19 T     0     0     0  0   0 SY f0271950      0          ?        0:00 sched
 8 S     0     1     0  0  41 20 f5b03338     96 f5b03508 ?        0:03 init
19 S     0     3     0  0   0 SY f5b02678      0 f028a794 ?       12:07 fsflush
 8 S     0   163     1  0  41 20 f5ca2980    635 f5ca2f84 ?        5:24 automoun
These options are useful for finding processes that are using a lot of CPU time, denoted by the information in the TIME column. Processes can also be traced to the owner via the UID column. A process is said to be "running away" if it is using most of the CPU resources. For a small number of process this may be normal behavior, however, most of the time this indicates errant behavior and the process should be terminated.

The kill command

The kill command terminates the specified process ID a running process. By default, kill attempts to terminate a process by sending the SIGTERM termination signal to the process. This is known as a graceful termination and the process will be able to handle any pending signals. To alter this default behavior a signal number may be specified so that a processes can be terminated more abruptly if and when necessary. For instance the signal SIGKILL causes immediate termination of a process and the signal SIGSTOP causes the process to stop executing.
#ps -f -u leighg
     UID   PID  PPID  C    STIME TTY      TIME CMD
  leighg   259   210  0   Jul 17 pts/0    0:01 -bash
  leighg   599   597  0   Jul 17 pts/3    0:02 -bash
  leighg 28466 28464  0 16:23:12 pts/1    0:00 -bash
  leighg 11682 11680  0   Jul 18 pts/6    0:01 -bash
To kill the process gracefully, type:
# kill 259
This would, in most cases, kill the process and the user would again be able to use the terminal. If this does not work, you might try:
# kill -9 259
More information is provided about the kill command from the man page.

Terms used: virtual memory, kernel, process.



[EdCert previous] [EdCert next] [EdCert top]