[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Performance Management Guide


Using the vmstat, iostat, netstat, and sar Commands

The vmstat, iostat, netstat, and sar commands have functional characteristics that make them useful for continuous monitoring of system performance. These commands can:

The following example shows samples of the periodic reports produced by these programs.

# vmstat 5 2
kthr     memory             page              faults        cpu
----- ----------- ------------------------ ------------ -----------
 r  b   avm   fre  re  pi  po  fr   sr  cy  in   sy  cs us sy id wa
 0  1 75318   142   0   0   0   0    0   0 299 1845 315  5  2 93  0
 0  1 75318   141   0   0   0   0    0   0 626 4949 842  8  6 87  0

See The vmstat Command (CPU), The vmstat Command (Memory), and Assessing Disk Performance with the vmstat Command for detailed discussions of the vmstat command.

# iostat 5 2
 
tty:      tin         tout   avg-cpu:  % user    % sys     % idle    % iowait
          0.0          0.5               5.2      1.8       92.7       0.3
                " Disk history since boot not available. "
 
 
tty:      tin         tout   avg-cpu:  % user    % sys     % idle    % iowait
          0.0         41.4               8.1      5.5       84.2       2.2
 
Disks:        % tm_act     Kbps      tps    Kb_read   Kb_wrtn
hdisk0           7.1      28.4       6.9          0       144
hdisk1           0.0       0.0       0.0          0         0
cd0              0.0       0.0       0.0          0         0

The system maintains a history of disk activity. If the history is disabled (smitty chgsys -> Continuously maintain DISK I/O history [false]) you see this message when running the iostat command: Disk history since boot not available. The interval disk I/O statistics are unaffected by this. For detailed discussion of this command, see The iostat Command and Assessing Disk Performance with the iostat Command.

# netstat -I tr0 5
    input   (tr0)      output           input   (Total)    output
 packets  errs  packets  errs colls  packets  errs  packets  errs colls
  725227     0   445748     0     0   799996     0   520517     0     0
       0     0        0     0     0        0     0        0     0     0
       2     0        0     0     0        2     0        0     0     0
CTRL C

Other useful netstat command options to use are -s and -v. See The netstat Command for details.

# sar -P ALL 5 2
 
AIX rugby 3 4 00058033A100    12/01/99
 
11:17:41 cpu    %usr    %sys    %wio   %idle
11:17:46  0        0       0       0     100
          1        0       0       0     100
          2        0       0       0     100
          3        0       0       0     100
          -        0       0       0     100
11:17:51  0        0       0       0     100
          1        0       0       0     100
          2        0       0       0     100
          3        0       0       0     100
          -        0       0       0     100
 
Average   0        0       0       0     100
          1        0       0       0     100
          2        0       0       0     100
          3        0       0       0     100
          -        0       0       0     100

For details on the sar command, see The sar Command and Assessing Disk Performance with the sar Command.

Remember that the first report from the vmstat, iostat, and netstat commands is for cumulative activity since the last system boot. The second report shows activity for the first 5-second interval. The sar command does not report the cumulative activity since the last system boot.

These commands are the basic foundation on which to construct a performance-monitoring mechanism. Shell scripts can be written to perform data reduction on the command output and warn of performance problems or record data on the status of the system when a problem is occurring. For example, a shell script could test the CPU idle percentage for zero and execute another shell script when that CPU-saturated condition occurred. A script such as:

# ps -ef | egrep -v "STIME|$LOGNAME" | sort +3 -r | head -n 15

would record the 15 active processes that had consumed the most CPU time recently (other than the processes owned by the user of the script).

Depending on the required level of sophistication, creating such a family of shell scripts can be a substantial project. Fortunately, there are packages available that require less development and setup and have considerably more function than the typical installation would want to implement locally.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]