sar
Manual Reference Pages - SAR (1)
NAME
sar - Collect, report, or save system activity information.
CONTENTS
Synopsis
Description
Options
Environment
Examples
Bugs
Files
Author
See Also
SYNOPSIS
sar [ -A ] [ -b ] [ -B ] [ -c ] [ -d ] [ -i interval ] [ -p ] [ -q ] [ -r ] [ -R ] [ -t ] [ -u ] [ -v ] [ -V ] [ -w ] [ -W ] [ -y ] [ -n { DEV | EDEV | NFS | NFSD | SOCK | ALL } ] [ -x { pid | SELF | ALL } ] [ -X { pid | SELF | ALL } ] [ -I { irq | SUM | ALL | XALL } ] [ -P { cpu | ALL } ] [ -o [ filename ] | -f [ filename ] ] [ -s [ hh:mm:ss ] ] [ -e [ hh:mm:ss ] ] [ interval [ count ] ]
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. The default value for the count parameter is 1. If its value is set to zero, then reports are generated continuously. The collected data can also be saved in the file specified by the -o filename flag, in addition to being displayed onto the screen. If filename is omitted, sar uses the standard system activity daily data file, the /var/log/sa/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. Exceptions are interrupts and disks data, for which the relevant options must be explicitly passed to sar (or to its backend sadc ) when the data file is created (see options below).
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.
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 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 is equivalent to specifying -bBcdqrRuvwWy -I SUM -I XALL -n ALL -P ALL.
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 is 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 will be selected. Collection of data in this manner is useful to characterize system usage over a period of time and determine peak usage hours.
Note: The sar command only reports on local activities.
OPTIONS
-A | This is equivalent to specifying -bBcdqrRuvwWy -I SUM -I XALL -n ALL -P ALL. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-b |
Report I/O and transfer rate statistics.
The following values are displayed:
tps
rtps
wtps
bread/s
bwrtn/s
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-B |
Report paging statistics. The following values are displayed:
pgpgin/s
pgpgout/s
fault/s
majflt/s
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-c |
Report process creation activity.
proc/s
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-d |
Report activity for each block device (kernels 2.4 and newer only).
When data is displayed, the device specification
dev m-n is generally used (
DEV column).
m is the major number of the device.
With recent kernels (post 2.5),
n is the minor number of the device, but is only a sequence number with
pre 2.5 kernels. Device names may also be pretty-printed if option -p
is used (see below). Values for fields avgqu-sz, await, svctm and %util
may be unavailable and displayed as 0.00 with some 2.4 kernels.
tps
rd_sec/s
wr_sec/s
avgrq-sz
avgqu-sz
await
svctm
%util
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-e [ hh:mm:ss ] | Set the ending time of the report. The default ending time is 18:00:00. Hours must be given in 24-hour format. This option can be used only when data are read from or written to a file (options -f or -o ). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-f [ filename ] | Extract records from filename (created by the -o filename flag). The default value of the filename parameter is the current daily data file, the /var/log/sa/sadd file. The -f option is exclusive of the -o option. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-i interval | Select data records at seconds as close as possible to the number specified by the interval parameter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-I { irq | SUM | ALL | XALL } | Report statistics for a given interrupt. irq is the interrupt number. Specifying multiple -I irq parameters on the command line will look at multiple independent interrupts. The SUM keyword indicates that the total number of interrupts received per second is to be displayed. The ALL keyword indicates that statistics from the first 16 interrupts are to be reported, whereas the XALL keyword indicates that statistics from all interrupts, including potential APIC interrupt sources, are to be reported. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-n { DEV | EDEV | NFS | NFSD | SOCK | ALL } |
Report network statistics.
With the DEV keyword, statistics from the network devices are reported. The following values are displayed: IFACE
rxpck/s
txpck/s
rxbyt/s
txbyt/s
rxcmp/s
txcmp/s
rxmcst/s
With the EDEV keyword, statistics on failures (errors) from the network devices are reported. The following values are displayed: IFACE
rxerr/s
txerr/s
coll/s
rxdrop/s
txdrop/s
txcarr/s
rxfram/s
rxfifo/s
txfifo/s
With the NFS keyword, statistics about NFS client activity are reported. The following values are displayed: call/s
retrans/s
read/s
write/s
access/s
getatt/s
With the NFSD keyword, statistics about NFS server activity are reported. The following values are displayed: scall/s
badcall/s
packet/s
udp/s
tcp/s
hit/s
miss/s
sread/s
swrite/s
saccess/s
sgetatt/s
With the SOCK keyword, statistics on sockets in use are reported. The following values are displayed: totsck
tcpsck
udpsck
rawsck
ip-frag
The ALL keyword is equivalent to specifying all the keywords above and therefore all the network activities are reported. |
-o [ filename ] | Save the readings in the file in binary form. Each reading is in a separate record. The default value of the filename parameter is the current daily data file, the /var/log/sa/sadd file. The -o option is exclusive of the -f option. | ||||||||||||||||||
-P { cpu | ALL } | Report 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 -u and -I SUM flags are meaningful with the -P flag. Note that processor 0 is the first processor. | ||||||||||||||||||
-p | Pretty-print device names. Use this option in conjunction with option -d. By default names are printed as dev m-n where m and n are the major and minor numbers for the device. Use of this option displays the names of the devices as they (should) appear in /dev. Name mappings are controlled by /etc/sysstat/sysstat.ioconf. | ||||||||||||||||||
-q |
Report queue length and load averages. The following values are displayed:
runq-sz
plist-sz
ldavg-1
ldavg-5
ldavg-15
| ||||||||||||||||||
-r |
Report memory and swap space utilization statistics.
The following values are displayed:
kbmemfree
kbmemused
%memused
kbbuffers
kbcached
kbswpfree
kbswpused
%swpused
kbswpcad
| ||||||||||||||||||
-R |
Report memory statistics. The following values are displayed:
frmpg/s
bufpg/s
campg/s
| ||||||||||||||||||
-s [ hh:mm:ss ] | Set 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. Hours must be given in 24-hour format. This option can be used only when data are read from a file (option -f ). | ||||||||||||||||||
-t | When reading data from a daily data file, indicate that sar should display the timestamps in the original locale time of the data file creator. Without this option, the sar command displays the timestamps in the user's locale time. | ||||||||||||||||||
-u |
Report CPU utilization. The following values are displayed:
%user
%nice
%system
%iowait
%steal
%idle
| ||||||||||||||||||
-v |
Report status of inode, file and other kernel tables.
The following values are displayed:
dentunusd
file-sz
inode-sz
super-sz
%super-sz
dquot-sz
%dquot-sz
rtsig-sz
%rtsig-sz
| ||||||||||||||||||
-V | Print version number then exit. | ||||||||||||||||||
-w |
Report system switching activity.
cswch/s
| ||||||||||||||||||
-W |
Report swapping statistics. The following values are displayed:
pswpin/s
pswpout/s
| ||||||||||||||||||
-x { pid | SELF | ALL } |
Report statistics for a given process.
pid is the process identification number. The
SELF keyword indicates that statistics are to be reported for the
sar process itself, whereas the
ALL keyword indicates that statistics are to be reported for all the system processes.
All these statistics cannot be saved to a file.
So this option will be ignored whenever -o option is used.
Specifying multiple
-x pid parameters on the command line will look at multiple independent processes.
At the present time, no more than 256 processes can be monitored
simultaneously.
The following values are displayed: minflt/s
majflt/s
%user
%system
nswap/s
CPU
| ||||||||||||||||||
-X { pid | SELF | ALL } |
Report statistics for the child processes of the process whose PID is
pid . The
SELF keyword indicates that statistics are to be reported for the child processes of the
sar process itself, whereas the
ALL keyword indicates that statistics are to be reported for all the child processes
of all the system processes.
All these statistics cannot be saved to a file.
So this option will be ignored whenever -o option is used.
Specifying multiple
-X pid parameters on the command line will look at multiple independent processes.
At the present time, no more than 256 processes can be monitored
simultaneously.
The following values are displayed:
cminflt/s
cmajflt/s
%cuser
%csystem
cnswap/s
| ||||||||||||||||||
-y |
Report TTY device activity. The following values are displayed:
rcvin/s
xmtin/s
framerr/s
prtyerr/s
brk/s
ovrun/s
Note that with recent 2.6 kernels, these statistics can be retrieved only by root. |
ENVIRONMENT
The sar command takes into account the following environment variables:
S_TIME_FORMAT | If this variable exists and its value is ISO then the current locale will be ignored when printing the date in the report header. The sar command will use the ISO 8601 format (YYYY-MM-DD) instead. |
S_TIME_DEF_TIME | If this variable exists and its value is UTC then sar will save its data in UTC time (data will still be displayed in local time). sar will also use UTC time instead of local time to determine the current daily data file located in the /var/log/sa directory. |
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/sa/sa16
Display memory, swap space and network statistics saved in daily data file 'sa16'.
sar -A
Display all the statistics saved in current daily data file.
BUGS
/proc filesystem must be mounted for the sar command to work.
All the statistics are not necessarily available, depending on the kernel version used.
FILES
/var/log/sa/sadd
Indicate the daily data file, where the dd parameter is a number representing the day of the month.
/proc contains various files with system statistics.
AUTHOR
Sebastien Godard (sysstat <at> wanadoo.fr)
SEE ALSO
sadc(8), sa1(8), sa2(8), sadf(1), isag(1), mpstat(1), iostat(1), vmstat(8)
http://perso.orange.fr/sebastien.godard/
Improve this page