Unix command to collect, report or save system activity information
This article contains instructions or advice. Wikipedia is not a guidebook; please help rewrite such content to be encyclopedic or move it to Wikiversity, Wikibooks, or Wikivoyage.(July 2023) (Learn how and when to remove this message)
Called regularly by cron, sadc does the monitoring and stores its measurements to files in the /var/log/sa/ folder. The sar client can be used to explore this data.
System Activity Report (sar) is a Unix System V-derived system monitor command used to report on various system loads, including CPU activity, memory/paging, interrupts, device load, network and swap space utilization. Sar uses /proc filesystem for gathering information.
Platform support
Sar was originally developed for the Unix System V operating system; it is available in AIX, HP-UX, Solaris and other System V based operating systems but it is not available for macOS or FreeBSD. Prior to 2013 there was a bsdsar tool, but it is now deprecated.
Most Linux distributions provide sar utility through the sysstat package.
Syntax
sar [-flags] [ -e time ] [ -f filename ] [-i sec ] [ -s time ]
-f
filename Uses filename as the data source for sar. The default is the current daily data file /var/adm/sa/sadd.
-e
time Selects data up to time. The default is 18:00.
-i
sec Selects data at intervals as close as possible to sec seconds.
Example
[user@localhost]$ sar# Displays current CPU activity.
Sysstat package
Additional to sar command, Linux sysstat package in Debian, RedHat Enterprise Linux and SuSE provides additional reporting tools:
sar(1):Collect, report, or save system activity information.–Linux User Commands Manual
sa1(8):Collect and store binary data in the system activity daily data file.–Linux Administration and Privileged Commands Manual
sa2(8):shell variant of sar, supporting the same flags as sar command which write a daily report in the /var/log/sa directory.–Linux Administration and Privileged Commands Manual
sadf(1):, similar to sar but can write its data in different formats (CSV, XML, etc.). This is useful to load performance data into a database, or import them in a spreadsheet to make graphs.