setup sysstat and sar in my ubuntu/debian systems

Start the install:

apt-get install sysstat

Once sysstat is installed we have to enable sar:

dpkg-reconfigure sysstat

or do it manually: or change the  value of ENABLED from “false” to “true” in “/etc/default/sysstat”.

Start this service:

/etc/init.d/sysstat start

Finally we force it to start on boot:

update-rc.d sysstat defaults

You can use sar to look at the current 24 hour stats or use the last week of logs from /var/log/sysstat

The resources range from cpu usage, memory, swap, io, networking, etc.

 

 

 

Step 1.  Install sysstat
sudo apt-get install sysstat

Step 2. Enable stat collection
sudo vi /etc/default/sysstat

#
# Default settings for /etc/init.d/sysstat, /etc/cron.d/sysstat
# and /etc/cron.daily/sysstat files
#

# Should sadc collect system activity informations? Valid values
# are “true” and “false”. Please do not put other values, they
# will be overwritten by debconf!
ENABLED=”false”

# Additional options passed to sa1 by /etc/init.d/sysstat
# and /etc/cron.d/sysstat
# By default contains the `-S DISK’ option responsible for
# generating disk statisitcs.
SA1_OPTIONS=”-S DISK”

# Additional options passed to sa2 by /etc/cron.daily/sysstat.
SA2_OPTIONS=””
~
~
~
~

change ENABLED=”false” to ENABLED=”true”
save the file

 

Step 3. Change the collection interval from every 10 minutes to every 2 minutes.
sudo vi /etc/cron.d/sysstat

# The first element of the path is a directory where the debian-sa1
# script is located
PATH=/usr/lib/sysstat:/usr/sbin:/usr/sbin:/usr/bin:/sbin:/bin

# Activity reports every 10 minutes everyday
5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1

# Additional run at 23:59 to rotate the statistics file
59 23 * * * root command -v debian-sa1 > /dev/null && debian-sa1 60 2
~
~
~
~

 
Change
5-55/10 * * * * root command -v debian-sa1 > /dev/null &&  debian-sa1 1 1
To
*/2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
save the file

 

Step 4. Restart sysstat
sudo service sysstat restart

Step 5. If you want to see all statistics you can type:
sar -A

Step 6. If you want to save the statistics for further analysis to a file use:
sudo sar -A > $(date +`hostname`-%d-%m-%y-%H%M.log)

References

man sysstat
man sar