sar: System statistics

Written by Benjamin Cane on 2011-08-12 | 1 min read

Sar is a utility that will grab cpu, disk i/o, memory, and network statistics on a 10 minute interval. Sar is great for grabbing system statistics quickly; I use sar whenever I'm doing any kind of performance tuning or troubleshooting.

To use sar all you need to do is install the sysstat package. The package will install a cron in /etc/cron.d that will kick off a sar capture every 10 minutes. If you want you can change this to every 5 minutes by modifying the crontab.

Sar will even keep a months worth of data in /var/log/sa/saXX where XX represents the day of month.

Example:

[[email protected] tmp]# sar  
Linux 2.6.35.13-92.fc14.i686 (bcane.virtuals.local)  08/08/2011  _i686_ (1 CPU)  

09:05:01 AM CPU %user %nice %system %iowait %steal %idle  
09:10:01 AM all 0.10 0.00 0.13 0.15 0.00 99.61  
09:15:02 AM all 0.29 6.90 1.59 14.22 0.00 77.01  
09:20:01 AM all 0.02 0.00 0.10 0.14 0.00 99.74  
09:25:01 AM all 0.02 0.00 0.10 0.03 0.00 99.86  
09:30:01 AM all 0.02 0.09 1.13 12.63 0.00 86.12  
09:35:01 AM all 0.02 0.00 0.13 0.46 0.00 99.39  
09:40:01 AM all 0.02 0.00 0.14 0.57 0.00 99.27

To read a specific days file you can specify it with the -f option.

[[email protected] tmp]# sar -f /var/log/sa/sa08  
Linux 2.6.35.13-92.fc14.i686 (bcane.virtuals.local)  08/08/2011  _i686_ (1 CPU)  

09:05:01 AM CPU %user %nice %system %iowait %steal %idle  
09:10:01 AM all 0.10 0.00 0.13 0.15 0.00 99.61  
09:15:02 AM all 0.29 6.90 1.59 14.22 0.00 77.01  
09:20:01 AM all 0.02 0.00 0.10 0.14 0.00 99.74  
09:25:01 AM all 0.02 0.00 0.10 0.03 0.00 99.86  
09:30:01 AM all 0.02 0.09 1.13 12.63 0.00 86.12  
09:35:01 AM all 0.02 0.00 0.13 0.46 0.00 99.39  
09:40:01 AM all 0.02 0.00 0.14 0.57 0.00 99.27  

Picture of Benjamin Cane

Benjamin's specialty is keeping the lights on for mission critical systems. He is currently building applications that enable high concurrency financial transactions.

Recently Benjamin published his first book; Red Hat Enterprise Linux Troubleshooting Guide. In addition to writing, he has several Open Source projects focused on making Ops easier. These projects include Automatron, a project enabling auto-healing infrastructure for the masses.


Publications

Identify, capture and resolve common issues faced by Red Hat Enterprise Linux administrators using best practices and advanced troubleshooting techniques

What people are saying:
Excellent, excellent resource for practical guidance on how to troubleshoot a wide variety of problems on Red Hat Linux. I particularly enjoyed how the author made sure to provide solid background and practical examples. I have a lot of experience on Red Hat but still came away with some great practical tools to add to my toolkit. - Amazon Review