Useful shortcuts for vi editor

Friday 10 October 2014

How to trace Linux CPU usage on system?

mpstat -P ALL 20
  •  Shows that CPU usage information related to each core and all cpu in every 20 seconds.
sar 10
  •  Shows that CPU usage information related to all cpu in every 10 seconds.
Examples:

oracle@alperdb:~> mpstat -P ALL 1
Linux 2.6.32.12-0.7-default (alperdb)  02/21/2014  _x86_64_

09:12:46 AM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
09:12:47 AM  all    0.53    0.00    0.00    0.53    0.00    0.00    0.00    0.00   98.94
09:12:47 AM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
09:12:47 AM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
09:12:47 AM    2    1.11    0.00    0.00    0.00    0.00    0.00    0.00    0.00   98.89
09:12:47 AM    3    1.14    0.00    0.00    2.27    0.00    0.00    0.00    0.00   96.59

oracle@alperdb:~> sar 10
Linux 2.6.32.12-0.7-default (alperdb)  02/21/2014  _x86_64_

09:16:13 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
09:16:23 AM     all      0.20      0.00      0.05      0.18      0.00     99.57
09:16:33 AM     all      0.90      0.00      0.32      0.22      0.00     98.56
09:16:43 AM     all      1.89      0.00      0.47      0.32      0.00     97.32