Sar is a system monitor command used to display system activity. Sar ts installed via the sysstat rpm. Use the command below to install sysstat.
[root@fedora ~]# yum -y install sysstat
Once installed you can check out the sysstat config file (/etc/sysconfig/sysstat) and configure how long to sar will keep your logfiles, on my system the default was 7 days. I changed this to 30 days.
The cron job for sar is located here (/etc/cron.d/sysstat) if you want to modify it as well.
Once installed and configured to your liking you must ensure that it starts and runs at boot time. I accomplished this via the command below.
[root@fedora ~]# chkconfig sysstat on && service sysstat start
Once up and running it will write its logs out to /var/log/sa, and you can read those files with the following command (sar -d <filename>, where filename is the name of the file that you want to read). Note that in the examples below, 3 is the interval, and 10 is the count.
Additionally you may run sar interactively, below are a few sample commands.
View disk i/o and transfer rate stats:
sar -b 3 10
View memory and swap space stats:
sar -r 3 10
View swapping stats:
sar -W 3 10
View network stats:
sar -n DEV 3 10
View CPU stats:
sar -P ALL 3 10
A minor thing – when you install sysstat package, you also add /etc/cron.d/sysstat file, which samples performance matrices once every 10 minutes, by default, and generates a simple text file (which you can read with kSar, if you’re not into parsing-by-your-eyes mode). The problem with 10 minutes averages, is that they say very little. Their stats are so normalized you can hardly do anything with that.
What I do is modify the sample time from */10 (once every 10 minutes) to */1 (once every minute). I also add the ‘-d’ flag to sa1, as it does not sample disk performance by defaults (starting at RHEL5 and above. I think this is the case for RHEL6, but I did not play much with it). Starting at that moment, you will have better statistics. You can post-mortem some of your problems after they are detected, and see if you can figure out what was the cause.
Anyhow, I enjoyed your blog. Might be back once a while 🙂
Ez