Linux SAR: Collect, Report, and Save System Activity

The System Activity Report (sar) utility is one of the most comprehensive performance monitoring tools available in the Linux operating system. Part of the sysstat package, sar enables system administrators to collect performance metrics automatically at set intervals, store the resulting data in compact binary files, and generate detailed historical or real-time reports covering CPU, memory, I/O, paging, and network subsystems.

How sar Collects System Information

The collection process does not originate directly from the interactive sar command itself. Instead, it relies on an underlying backend utility named sadc (System Activity Data Collector).

  1. Kernel Interfaces: At scheduled intervals, sadc queries the Linux kernel interfaces, specifically reading virtual pseudo-filesystems such as /proc (e.g., /proc/stat, /proc/meminfo, /proc/diskstats, /proc/net/dev) and /sys.
  2. Scheduling Daemons: Modern Linux systems automate this collection using either systemd timers (sysstat-collect.timer) or standard cron jobs (/etc/cron.d/sysstat). Typically, a collection script runs every 10 minutes (or at custom defined frequencies) to sample current operating metrics.
  3. Internal Timers: For immediate data collection, executing sar directly with an interval and count parameter (such as sar 2 5) prompts the utility to take immediate snapshots directly from /proc, calculating the delta between intervals to determine real-time utilization rates.

How sar Saves System Data

To minimize storage overhead and processing impact on production servers, data is saved in a raw, optimized binary format rather than plain text.

How sar Reports System Metrics

The sar front-end command reads the generated binary data and translates it into human-readable tables, allowing users to query either live data or past performance metrics.