On the Solaris operating system, the sar command collects, reports, or saves system activity information.

Description

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 count and interval parameters, writes information the specified number of times spaced at the specified intervals in seconds. If the interval parameter is set to zero, the sar command displays the average statistics for the time since the system was started. If the interval parameter is specified without the count parameter, then reports are generated continuously. The collected data can also be saved in the file specified by the -o file name flag, in addition to being displayed onto the screen. If file name is omitted, sar uses the standard system activity daily data file, the /var/log/sysstat/sadd file, where the dd parameter indicates the current day. By default, all the data available from the kernel are saved in the data file.

  • Description
  • Syntax
  • Environment
  • Files
  • Examples
  • Related commands
  • Linux commands help

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. It is also possible to enter -1, -2 (etc.) as an argument to sar to display data of that days ago. For example, -1 points at the standard system activity file of yesterday.

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 processor and global statistics among all processors.

You can select information about specific system activities using flags. Not specifying any flags selects only CPU activity. Specifying the -A flag selects all possible 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 + nice + system), the workload sampled is CPU-bound.

If multiple samples and multiple reports are desired, it is convenient to specify an output file for the sar command. Run the sar command as a background process. The syntax for this is:

sar -o datafile interval count >/dev/null 2>&1 &

All data are captured in binary form and saved to a file (datafile). The data can then be selectively displayed with the sar command using the -f option. Set the interval and count parameters to select count records at interval second intervals. If the count parameter is not set, all the records saved in the file is selected. Collection of data in this manner is useful to characterize system usage over a period and determine peak usage hours.

Note: The sar command only reports on local activities.

Syntax

sar [-A] [-B] [-b] [-C] [-d] [-F] [-H] [-h] [-p] [-q] [-R] [-r] [-S] [-t] [-u [ALL]] [-V] [-v] [-W] [-w] [-y] [-I {int [,…] | SUM | ALL | XALL}] [-P {cpu [,…] | ALL}] [-m {keyword [,…] | ALL}] [-n {keyword [,…] | ALL}] [-j {ID | LABEL | PATH | UUID | …}] [-f [file name] | -o [file name] | -[0-9]+] [-i interval] [-s [hh:mm:ss]] [-e [hh:mm:ss]] [interval [count]]

Options

Environment

The sar command takes into account the following environment variables:

Possible keywords are CPU, FAN, FREQ, IN, TEMP and USB.

With the CPU keyword, statistics about CPU are reported. The following value is displayed:

With the FAN keyword, statistics about fans speed are reported. The following values are displayed:

With the FREQ keyword, statistics about CPU clock frequency are reported. The following value is displayed:

With the IN keyword, statistics about voltage inputs are reported. The following values are displayed:

With the TEMP keyword, statistics about device temperatures are reported. The following values are displayed:

With the USB keyword, the sar command takes a snapshot of all the USB devices currently plugged into the system. At the end of the report, sar displays a summary of all those USB devices. The following values are displayed:

Possible keywords are DEV, EDEV, NFS, NFSD, SOCK, IP, EIP, ICMP, EICMP, TCP, ETCP, UDP, SOCK6, IP6, EIP6, ICMP6, EICMP6 and UDP6.

With the DEV keyword, statistics from the network devices are reported. The following values are displayed:

With the EDEV keyword, statistics on failures (errors) from the network devices are reported. The following values are displayed:

With the NFS keyword, statistics about NFS client activity are reported. The following values are displayed:

With the NFSD keyword, statistics about NFS server activity are reported. The following values are displayed:

With the SOCK keyword, statistics on sockets in use are reported (IPv4). The following values are displayed:

With the IP keyword, statistics about IPv4 network traffic are reported. Note that IPv4 statistics depend on sadc option “-S SNMP” to be collected. The following values are displayed (formal SNMP names between square brackets):

With the EIP keyword, statistics about IPv4 network errors are reported. Note that IPv4 statistics depend on sadc option “-S SNMP” to be collected. The following values are displayed (formal SNMP names between square brackets):

With the ICMP keyword, statistics about ICMPv4 network traffic are reported. Note that ICMPv4 statistics depend on sadc option “-S SNMP” to be collected. The following values are displayed (formal SNMP names between square brackets):

With the EICMP keyword, statistics about ICMPv4 error messages are reported. Note that ICMPv4 statistics depend on sadc option “-S SNMP” to be collected. The following values are displayed (formal SNMP names between square brackets):

With the TCP keyword, statistics about TCPv4 network traffic are reported. Note that TCPv4 statistics depend on sadc option “-S SNMP” to be collected. The following values are displayed (formal SNMP names between square brackets):

With the ETCP keyword, statistics about TCPv4 network errors are reported. Note that TCPv4 statistics depend on sadc option “-S SNMP” to be collected. The following values are displayed (formal SNMP names between square brackets):

With the UDP keyword, statistics about UDPv4 network traffic are reported. Note that UDPv4 statistics depend on sadc option “-S SNMP” to be collected. The following values are displayed (formal SNMP names between square brackets):

With the SOCK6 keyword, statistics on sockets in use are reported (IPv6). Note that IPv6 statistics depend on sadc option “-S IPV6” to be collected. The following values are displayed:

With the IP6 keyword, statistics about IPv6 network traffic are reported. Note that IPv6 statistics depend on sadc option “-S IPV6” to be collected. The following values are displayed (formal SNMP names between square brackets):

With the EIP6 keyword, statistics about IPv6 network errors are reported. Note that IPv6 statistics depend on sadc option “-S IPV6” to be collected. The following values are displayed (formal SNMP names between square brackets):

With the ICMP6 keyword, statistics about ICMPv6 network traffic are reported. Note that ICMPv6 statistics depend on sadc option “-S IPV6” to be collected. The following values are displayed (formal SNMP names between square brackets):

With the EICMP6 keyword, statistics about ICMPv6 error messages are reported. Note that ICMPv6 statistics depend on sadc option “-S IPV6” to be collected. The following values are displayed (formal SNMP names between square brackets):

With the UDP6 keyword, statistics about UDPv6 network traffic are reported. Note that UDPv6 statistics depend on sadc option “-S IPV6” to be collected. The following values are displayed (formal SNMP names between square brackets):

Files

Examples

sar -u 2 5

Report CPU utilization for each 2 seconds. 5 lines are displayed.

sar -I 14 -o int14.file 2 10

Report statistics on IRQ 14 for each 2 seconds. 10 lines are displayed. Data are stored in a file called int14.file.

sar -r -n DEV -f /var/log/sysstat/sa16

Display memory and network statistics saved in daily data file ‘sa16’.

sar -A

Display all the statistics saved in current daily data file.

iostat — Report CPU and I/O statistics for devices and partitions.vmstat — Report statistics about virtual memory usage.