sar(1)
Collect, report, and save system activity information including CPU, memory, disk I/O, and network statistics.
Synopsis
sar [OPTIONS] [interval [count]]Description
sar (System Activity Reporter) collects and displays cumulative activity counters from the operating system. It can monitor CPU usage, memory and swap space, disk I/O, network interfaces, and process statistics. sar is typically run by the sysstat package and stores historical data in system activity files for trend analysis and performance troubleshooting.
When run without options, sar displays CPU activity. Specify an interval (in seconds) and optional count to get periodic reports. Historical data can be read from files in /var/log/sa/ using the -f flag.
Common options
| Flag | What it does |
|---|---|
-u | Report CPU utilization (default); show user, system, iowait, and idle percentages |
-b | Report I/O and transfer rate statistics (reads/writes per second, I/O efficiency) |
-r | Report memory and swap space utilization in KB or MB |
-n | Report network statistics; use with DEV (interfaces), EDEV (errors), TCP, UDP, ICMP, SOCK |
-d | Report disk device I/O statistics (reads, writes, transfers per second, utilization %) |
-p | Report per-processor CPU statistics instead of aggregated values |
-f FILE | Read activity data from specified file instead of current data (e.g., /var/log/sa/sa01) |
-s HH:MM:SS | Start time for displaying data when reading from a file |
-e HH:MM:SS | End time for displaying data when reading from a file |
-A | Report all statistics; equivalent to -u -b -r -n -d -q -v -w |
Examples
Display CPU activity every 1 second for 5 iterations
sar 1 5Show per-processor CPU statistics every 2 seconds for 3 iterations
sar -u -p 2 3Display I/O statistics (reads, writes, transfers) every 5 seconds for 10 iterations
sar -b 5 10Report current memory and swap space usage
sar -rShow network interface statistics (packets/bytes transmitted/received) every 1 second
sar -n DEV 1 3Display disk I/O activity (reads, writes, utilization) every 2 seconds for 4 iterations
sar -d 2 4Read historical data from the 15th day's file and display statistics between 10:00 AM and noon
sar -f /var/log/sa/sa15 -s 10:00:00 -e 12:00:00Display all available statistics (CPU, I/O, memory, network, disk) once
sar -A 1 1