Getting started with sar


sar on Linux

If the sysstat package isn't installed on your Linux system (which it generally isn't by default), you can easily grab a copy with your favorite Linux installer -- typically one of the following commands will do the job:

yum install sysstat
apt-get install sysstat
rpm -ivh sysstat-10.0.2-20.18.2.x86	(the package name will vary)

Use yum or apt-get if available. These commands let you sit back and watch the system figure out exactly what it needs and do the work for you. I just installed sysstat (the package that contains the sar components) on a Fedora 17 system and got a "cannot retrieve metalink for repository updates" error, but a second try and all was well.

The install should add a cron file for you as /etc/cron.d/systat. That file will contain entries like these:

# run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib/sa/sa1 1 1
# generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib/sa/sa2 -A

As you can see, this installation of sar is going to collect performance data every ten minutes -- every day of the week. Daily summaries will be prepared shortly before midnight (11:53 PM).

The sar command itself is only one component of the sysstat package. The sadc component collects performance data and stores it in a binary data file. The sa1 component that you see listed in the second line above is a wrapper for sadc that works in cron jobs.

The sa2 script gets sar to print a report in ASCII format from the binary information that sadc has stored in the /var/log/sa/sa## files where ## is the day of the month that information was collected. The daily reports will be named /var/log/sa/sar##. When you first install the sysstat package, you will see no files in /var/log/sa. Within ten minutes, you'll see your first sa## file and, at the end of the day, your first sar## file.

sar on Solaris

On Solaris systems, sar will be installed by default. To get it running, all you have to do is uncomment the bottom three lines in the crontab file belonging to the user "sys" (shown below). Using the default settings, you will collect performance data every twenty minutes during normal business hours (8:00 AM to 6:00 PM). During other hours, it runs only once an hour (first line). You have to look at the first two of the three lines to see this. The first says "run once an hour around the clock". The second says "run at 20 minutes and 40 minutes after the hour between 8:20 AM and 5:40".

At 6:05 PM, Monday through Friday, sa2 runs, preparing the daily report. The -s and -e arguments specify the start and end times for these reports. This creates the /var/log/sar## files described earlier.

#ident  "@(#)sys        1.5     92/07/14 SMI"   /* SVr4.0 1.2   */
# The sys crontab should be used to do performance collection.
Join us:






Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Ask a Question