Collects, reports, or saves system activity information.
/usr/sbin/sar [ { -A | [ -a ] [ -b ] [ -c ] [ -k ] [ -m ] [ -q ] [ -r ] [ -u ] [ -v ] [ -w ] [ -y ] } ] [ -P ProcessorIdentifier, ... | ALL ] [ -ehh [ :mm [ :ss ] ] ] [ -fFile ] [ -iSeconds ] [ -oFile ] [ -shh [ :mm [ :ss ] ] ] [ Interval [ Number ] ]
The sar command writes to standard output the contents of selected cumulative activity counters in the operating system. The accounting system, based on the values in the Number and Interval parameters, writes information the specified number of times spaced at the specified intervals in seconds. The default sampling interval for the Number parameter is 1 second. The collected data can also be saved in the file specified by the -o File flag.
The sar command extracts and writes to standard output records previously saved in a file. This file can be either the one specified by the -f flag or, by default, the standard system activity daily data file, the /var/adm/sa/sadd file, where the dd parameter indicates the current day.
Without the -P flag, the sar command reports system-wide (global among all processors) statistics, which are calculated as averages for values expressed as percentages, and as sums otherwise. If the -P flag is given, the sar command reports activity which relates to the specified processor or processors. If -P ALL is given, the sar command reports statistics for each individual processor, followed by system-wide statistics.
You can select information about specific system activities using flags. Not specifying any flags selects only system unit activity. Specifying the -A flag selects all activities.
The default version of the sar command (CPU utilization report) might be one of the first facilities the user runs to begin system activity investigation, because it monitors major system resources. If CPU utilization is near 100 percent (user + system), the workload sampled is CPU-bound. If a considerable percentage of time is spent in I/O wait, it implies that CPU execution is blocked waiting for disk I/O. The I/O may be required file accesses or it may be I/O associated with paging due to a lack of sufficient memory.
Note: The time the system spends waiting for remote file access is not accumulated in the I/O wait time. If CPU utilization and I/O wait time for a task are relatively low, and the response time is not satisfactory, consider investigating how much time is being spent waiting for remote I/O. Since no high-level command provides statistics on remote I/O wait, trace data may be useful in observing this.
If multiple samples and multiple reports are desired, it is convenient to specify an output file for the sar command. Direct the standard output data from the sar command to /dev/null and run the sar command as a background process. The syntax for this is:
sar -A -o data.file interval count > /dev/null &
All data is captured in binary form and saved to a file (data.file ). The data can then be selectively displayed with the sar command using the -f option.
The sar command calls a process named sadc to access system data. Two shell scripts (/usr/lib/sa/sa1 and /usr/lib/sa/sa2 ) are structured to be run by the cron command and provide daily statistics and reports. Sample stanzas are included (but commented out) in the /var/spool/cron/crontab/adm crontab file to specify when the cron daemon should run the shell scripts. Collection of data in this manner is useful to characterize system usage over a period of time and determine peak usage hours.
You can insert a dummy record into the standard system activity daily data file at the time of system start by uncommenting corresponding lines in the /etc/rc script. The sar command reports time change not positive for any record where CPU times are less than the previous record. This occurs if you reboot the system with the dummy record insertion lines in /etc/rc commented out.
Note: The sar command only reports on local activities.
You can use the Web-based System Manager System application (wsm system fast path) to run this command. You could also use the System Management Interface Tool (SMIT) smit sar fast path to run this command.
-P ProcessorIdentifier, ... | ALL | ||||||||||
Reports per-processor statistics for the specified processor or processors. Specifying the ALL keyword reports statistics for each individual processor, and globally for all processors . Of the flags which specify the statistics to be reported, only the -a, -c, -m, -u, and -w flags are meaningful with the -P flag. | ||||||||||
-q | ||||||||||
Reports queue statistics. The following values are displayed:
Note: A blank value in any column indicates that the associated queue is empty. | ||||||||||
-r | Reports paging statistics. The following values are displayed:
| |||||||||
-s hh[:mm[:ss]] | Sets the starting time of the data, causing the sar command to extract records time-tagged at, or following, the time specified. The default starting time is 08:00. | |||||||||
-u | Reports
per processor or system-wide statistics. When used with the -P flag, the information is provided for each specified processor; otherwise, it is provided only system-wide. Because the -u flag information is expressed as percentages, the system-wide information is simply the average of each individual processor's statistics. Also, the I/O wait state is defined system-wide and not per processor.
The following values are displayed:
Note: The sar command reports system unit activity if no other specific content options are requested. | |||||||||
-v | Reports status of the process,
kernel-thread,
i-node, and file tables. The following values are displayed:
|
-w | Reports system switching activity.
When used with the -P flag, the information is provided for each specified processor; otherwise, it is provided only system-wide.
The following value is displayed:
| ||||||||||||
-y | Reports tty device activity per second.
|
Access Control: These commands should grant execute (x) access only to members of the adm group.
sar
sar -y -r 2 20
sar -o temp 60 10
sar -u -P 0,1This produces output similar to the following:
cpu %usr %sys %wio %idle 0 45 45 5 5 1 27 65 3 5
sar -mu -P ALLOn a four-processor system, this produces output similar to the following (the last line indicates system-wide statistics for all processors):
cpu msgs/s sema/s %usr %sys %wio %idle 0 7 2 45 45 5 5 1 5 0 27 65 3 5 2 3 0 55 40 1 4 3 4 1 48 41 4 7 - 19 3 44 48 3 5
/usr/sbin/sar | Contains the sar command. |
/bin/sar | Indicates the symbolic link to the sar command. |
/var/adm/sa/sadd | Indicates the daily data file, where the dd parameter is a number representing the day of the month. |
The sadc command, sa1 command, sa2 command.
Accounting Overview in the AIX Version 4.3 System Management Guide: Operating System and Devices.
Setting Up an Accounting System in the AIX Version 4.3 System Management Guide: Operating System and Devices.
Accounting Commands Overview in the AIX Version 4.3 System Management Guide: Operating System and Devices lists accounting commands that can be run automatically or entered from the keyboard.
AIX Performance Monitoring and Tuning Commands in AIX Versions 3.2 and 4 Performance Tuning Guide.
Setting up and running Web-based System Management in AIX Version 4.3 System Management Guide: Operating System and Devices.