Candid photograph of a Linux server terminal with a soft olive-green glow against a dark slate background, conveying a calm technical atmosphere.

Step-by-step guides for system administrators — covering command-line basics, web server setup, and preparation material for technical interviews.

Browse Tutorials

Using Sar To Collect And Report System Activity

Linux performance problems are easier to diagnose when you have historical evidence. The sar utility, supplied by the sysstat package, records CPU, memory, load, disk, network, and process activity so administrators can compare normal behaviour with an incident.

On RHEL, CentOS, and Fedora systems, sar is especially useful for finding patterns that tools such as top cannot show after the event. It can reveal whether a server became slow because of CPU saturation, swapping, storage latency, or a sudden burst of network traffic.

The collected reports also provide useful operational context for Australian environments. A scheduled job running during Sydney business hours may overlap with traffic from Melbourne, while a server in Perth can have a different local operating schedule. Correct time-zone handling is therefore important when matching system activity with logs and alerts.

Command Reports Useful For
sar -u CPU usage Finding busy or idle processors
sar -r Memory and swap Detecting pressure and swapping
sar -b Block I/O Checking storage throughput
sar -n DEV Network interfaces Measuring traffic and errors
sar -q Load and run queue Reviewing system demand

Installing And Enabling Sysstat

Install the package with the distribution’s standard package manager:

sudo dnf install -y sysstat

On older CentOS systems, use yum instead. The package includes sar, sadc, and collection jobs that write binary activity files under /var/log/sa/. Confirm the installation with:

sar -V

Enable collection with the appropriate service:

sudo systemctl enable --now sysstat
sudo systemctl status sysstat

Some older releases use sysstat-collect or cron entries rather than a single sysstat service. Check available units with systemctl list-unit-files | grep sysstat, then inspect /etc/cron.d/sysstat if scheduled collection is managed by cron.

The default interval is commonly ten minutes, but the exact setting depends on the distribution. Review /etc/sysconfig/sysstat or /etc/sysstat/sysstat and adjust the collection interval only when the extra disk and CPU overhead is justified.

Reading Live CPU And Load Data

Running sar without a file reads activity collected for the current day. To sample the system immediately, specify an interval and count:

sar -u 5 12

This records twelve samples, five seconds apart. The %user and %system fields show time spent running user applications and kernel operations. %iowait indicates time CPUs were idle while storage operations were pending, although it should be interpreted alongside disk latency and application behaviour.

The %idle value is the percentage of time processors were idle. Low idle time over a sustained period can indicate CPU pressure, but a high load average does not always mean CPU exhaustion. Processes blocked on storage can raise load while CPUs remain partially idle.

Use this command to inspect load and run-queue information:

sar -q 1 10

Compare runq-sz with the number of CPU cores. A queue consistently larger than available processing capacity deserves investigation, particularly during business-hours workloads in Sydney or Melbourne.

Checking Memory And Swap Pressure

Memory statistics are available with:

sar -r

Important fields include %memused, kbavail, and %swpused. Available memory is generally more useful than free memory because Linux uses spare RAM for caches. A server can show little free memory while still having ample reclaimable space.

Swap activity is more revealing than swap allocation alone:

sar -W

The pswpin/s and pswpout/s values show pages moving into and out of swap. Sustained activity can cause slow response times, especially on virtual machines with limited memory. Check processes with free -h, vmstat 1, and application-specific metrics before adding RAM or changing kernel settings.

For a historical report, specify the date file:

sar -r -f /var/log/sa/sa$(date +%d)

The file naming convention can vary slightly between releases. Use ls -l /var/log/sa/ to verify the available records.

Analysing Disk And Network Activity

Disk statistics help separate CPU problems from storage bottlenecks:

sar -d
sar -b

Depending on the sysstat version, sar -d reports device-level throughput, requests, and utilisation, while sar -b summarises transfer rates. High utilisation with increasing wait times can point to saturated disks, a busy SAN, or noisy-neighbour activity in a virtual environment.

Network reports are collected with:

sar -n DEV
sar -n EDEV

DEV displays receive and transmit rates for interfaces. EDEV highlights errors, drops, and failures. Ignore loopback traffic when assessing external load, and identify whether an interface is physical, bonded, virtual, or a container bridge.

For an application hosted in an Australian cloud region such as Sydney or Melbourne, compare interface traffic with load balancer, firewall, and provider metrics. A burst may be legitimate customer activity rather than a local fault, while packet errors may indicate an interface or upstream networking issue.

Producing Historical Reports

Use -s and -e to limit a report to a period of interest:

sar -u -s 09:00:00 -e 17:00:00

The output uses the server’s local time zone. Confirm it with:

timedatectl

This matters across Australian sites: Brisbane uses AEST year-round, Perth uses AWST, and Sydney and Melbourne switch between AEST and AEDT. A report covering a daylight-saving transition may contain an apparent time jump, so correlate it with journalctl and application logs carefully.

Combine several views during an incident:

sar -q -r -n DEV -f /var/log/sa/sa15

Save a report for later review:

sar -u -r -b -n DEV -f /var/log/sa/sa15 > /tmp/server-report.txt

Preserve the relevant report with the incident record, note the server time zone, and compare the affected interval with normal days. On the next investigation, begin by running sar -u 5 12, then inspect the matching historical file in /var/log/sa/.