by Ramesh Natarajan on March 29, 2011
Using sar you can monitor performance of various Linux subsystems (CPU, Memory, I/O..) in real time.
Using sar, you can also collect all performance data on an on-going basis, store them, and do historical analysis to identify bottlenecks.
Sar is part of the sysstat package.
This article explains how to install and configure sysstat package (which contains sar utility) and explains how to monitor the following Linux performance statistics using sar.
- Collective CPU usage
- Individual CPU statistics
- Memory used and available
- Swap space used and available
- Overall I/O activities of the system
- Individual device I/O activities
- Context switch statistics
- Run queue and load average data
- Network statistics
- Report sar data from a specific time
This is the only guide you’ll need for sar utility. So, bookmark this for your future reference.
I. Install and Configure Sysstat
Install Sysstat Package
First, make sure the latest version of sar is available on your system. Install it using any one of the following methods depending on your distribution.
sudo apt-get install sysstat (or) yum install sysstat (or) rpm -ivh sysstat-10.0.0-1.i586.rpm
Install Sysstat from Source
Download the latest version from sysstat download page.
You can also use wget to download the
wget http://pagesperso-orange.fr/sebastien.godard/sysstat-10.0.0.tar.bz2 tar xvfj sysstat-10.0.0.tar.bz2 cd sysstat-10.0.0 ./configure --enable-install-cron
Note: Make sure to pass the option –enable-install-cron. This does the following automatically for you. If you don’t configure sysstat with this option, you have to do this ugly job yourself manually.
- Creates /etc/rc.d/init.d/sysstat
- Creates appropriate links from /etc/rc.d/rc*.d/ directories to /etc/rc.d/init.d/sysstat to start the sysstat automatically during Linux boot process.
- For example, /etc/rc.d/rc3.d/S01sysstat is linked automatically to /etc/rc.d/init.d/sysstat
After the ./configure, install it as shown below.
make make install
Note: This will install sar and other systat utilities under /usr/local/bin
Once installed, verify the sar version using “sar -V”. Version 10 is the current stable version of sysstat.
$ sar -V sysstat version 10.0.0 (C) Sebastien Godard (sysstat orange.fr)
Finally, make sure sar works. For example, the following gives the system CPU statistics 3 times (with 1 second interval).
$ sar 1 3 Linux 2.6.18-194.el5PAE (dev-db) 03/26/2011 _i686_ (8 CPU) 01:27:32 PM CPU %user %nice %system %iowait %steal %idle 01:27:33 PM all 0.00 0.00 0.00 0.00 0.00 100.00 01:27:34 PM all 0.25 0.00 0.25 0.00 0.00 99.50 01:27:35 PM all 0.75 0.00 0.25 0.00 0.00 99.00 Average: all 0.33 0.00 0.17 0.00 0.00 99.50
Utilities part of Sysstat
Following are the other sysstat utilities.
- sar collects and displays ALL system activities statistics.
- sadc stands for “system activity data collector”. This is the sar backend tool that does the data collection.
- sa1 stores system activities in binary data file. sa1 depends on sadc for this purpose. sa1 runs from cron.
- sa2 creates daily summary of the collected statistics. sa2 runs from cron.
- sadf can generate sar report in CSV, XML, and various other formats. Use this to integrate sar data with other tools.
- iostat generates CPU, I/O statistics
- mpstat displays CPU statistics.
- pidstat reports statistics based on the process id (PID)
- nfsiostat displays NFS I/O statistics.
- cifsiostat generates CIFS statistics.
This article focuses on sysstat fundamentals and sar utility.
Rest here: http://www.thegeekstuff.com/2011/03/sar-examples/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+TheGeekStuff+%28The+Geek+Stuff%29&utm_content=Google+Reader
- imabonehead: Linux Security: Securing and Hardening Linux Production Systems (Linux Security Cookbook / HOWTO / Guide) (puschitz.com)
- Performance Monitoring (mohibalvi.wordpress.com)
- SourceForge.net: GettingStarted – bigdata (sourceforge.net)
- Time-saving tips for Linux (quora.com)
- 2010/10/08 http://ninite.com/linux/makeuseof – very good collection of utilities for .deb based distro’s
- 2010/09/04 Fedora Linux – Display information about users currently logged on – whowatch
- 2010/09/04 Remove some path from the PATH variable temporarily.
- 2010/07/14 Configurable Linux Distro You Might Want To Try – Fedora