Sar

From Linuxintro

sar allows you to monitor your computer resources' usage over a time frame.

Use it

To install and use sar find out your distribution and proceed accordingly:

Ubuntu 10.04

sudo apt-get install sysstat
/etc/init.d/sysstat start
  • after a day you will find statistics in /var/log/sysstat

Examples

CPU statistics

tweedleburg:~ # sar 10
Linux 2.6.32.12-0.7-default (tweedleburg)    12/05/2010      _x86_64_ 

05:05:02 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
05:05:12 AM     all      7.16      0.00      0.79      0.00      0.00     92.04
05:05:22 AM     all      7.05      0.00      0.77      0.02      0.00     92.16

network and ram

The following collects data for RAM (-r) and network (-n) all 10 seconds

tweedleburg:~ # sar -r -n DEV 10
Linux 2.6.32.12-0.7-default (tweedleburg)    12/05/2010      _x86_64_

05:23:09 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
05:23:19 AM  42832588   6586776     13.33    284956   3922980   1816792      3.68

05:23:09 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
05:23:19 AM        lo      1.51      1.51      0.18      0.18      0.00      0.00      0.00
05:23:19 AM      eth0     37.10      1.71      3.51      0.25      0.00      0.00      0.00
05:23:19 AM      eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00
05:23:19 AM      eth2     24.70     17.94      3.59      2.80      0.00      0.00      0.10
05:23:19 AM      eth3      0.00      0.00      0.00      0.00      0.00      0.00      0.00

05:23:19 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
05:23:29 AM  42828780   6590584     13.34    284964   3922980   1820588      3.68

05:23:19 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
05:23:29 AM        lo      2.05      2.05      0.21      0.21      0.00      0.00      0.00
05:23:29 AM      eth0     40.02      6.46      3.87      6.09      0.00      0.00      0.00
05:23:29 AM      eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00
05:23:29 AM      eth2     17.03      9.78      2.14      1.53      0.00      0.00      0.10
05:23:29 AM      eth3      0.00      0.00      0.00      0.00      0.00      0.00      0.00

See also