$linuxjunkies
>

sar(1)

Collect, report, and save system activity information including CPU, memory, disk I/O, and network statistics.

UbuntuDebianFedoraArch

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

FlagWhat it does
-uReport CPU utilization (default); show user, system, iowait, and idle percentages
-bReport I/O and transfer rate statistics (reads/writes per second, I/O efficiency)
-rReport memory and swap space utilization in KB or MB
-nReport network statistics; use with DEV (interfaces), EDEV (errors), TCP, UDP, ICMP, SOCK
-dReport disk device I/O statistics (reads, writes, transfers per second, utilization %)
-pReport per-processor CPU statistics instead of aggregated values
-f FILERead activity data from specified file instead of current data (e.g., /var/log/sa/sa01)
-s HH:MM:SSStart time for displaying data when reading from a file
-e HH:MM:SSEnd time for displaying data when reading from a file
-AReport all statistics; equivalent to -u -b -r -n -d -q -v -w

Examples

Display CPU activity every 1 second for 5 iterations

sar 1 5

Show per-processor CPU statistics every 2 seconds for 3 iterations

sar -u -p 2 3

Display I/O statistics (reads, writes, transfers) every 5 seconds for 10 iterations

sar -b 5 10

Report current memory and swap space usage

sar -r

Show network interface statistics (packets/bytes transmitted/received) every 1 second

sar -n DEV 1 3

Display disk I/O activity (reads, writes, utilization) every 2 seconds for 4 iterations

sar -d 2 4

Read 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:00

Display all available statistics (CPU, I/O, memory, network, disk) once

sar -A 1 1

Related commands