This package includes system performance tools for Linux (Red Hat Linux / RHEL includes these tools by default).And for Debian or Ubuntu use "apt-get"
# apt-get install sysstat
Display the utilization of each CPU individually using mpstat
If you are using SMP (Multiple CPU) system, use mpstat command to display the utilization of each CPU individually. It report processors related statistics. For example, type command:# mpstat
Output:
Linux 2.6.15.4 (debian) Thursday 06 April 2006
05:13:05 IST CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
05:13:05 IST all 16.52 0.00 2.87 1.09 0.07 0.02 0.00 79.42 830.06
The mpstat command display activities for each available processor, processor 0 being the first one. Global average activities among all processors are also reported. The mpstat command can be used both on SMP and UP machines, but in the latter, only global average activities will be printed.:# mpstat -P ALL
Output:
Linux 2.6.15.4 (wwwportal1.xxxx.co.in) Thursday 06 April 2006
05:14:58 IST CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
05:14:58 IST all 16.46 0.00 2.88 1.08 0.07 0.02 0.00 79.48 835.96
05:14:58 IST 0 16.46 0.00 2.88 1.08 0.07 0.02 0.00 79.48 835.96
05:14:58 IST 1 15.77 2.70 3.17 2.01 0.05 0.03 0.00 81.44 822.54
Another output from my HP Dual Opteron 64 bit server:# mpstat -P ALL
Output:
Linux 2.6.5-7.252-smp (ora9.xxx.in) 04/07/06
07:44:18 CPU %user %nice %system %iowait %irq %soft %idle intr/s
07:44:18 all 3.01 57.31 0.36 0.13 0.01 0.00 39.19 1063.46
07:44:18 0 5.87 69.47 0.44 0.05 0.01 0.01 24.16 262.11
07:44:18 1 1.79 48.59 0.36 0.23 0.00 0.00 49.02 268.92
07:44:18 2 2.19 42.63 0.28 0.16 0.01 0.00 54.73 260.96
07:44:18 3 2.17 68.56 0.34 0.06 0.03 0.00 28.83 271.47
Report CPU utilization using sar command
You can display today’s CPU activity, with sar command:# sar
Output:
Linux 2.6.9-42.0.3.ELsmp (dellbox.xyz.co.in) 01/13/2007
12:00:02 AM CPU %user %nice %system %iowait %idle
12:10:01 AM all 1.05 0.00 0.28 0.04 98.64
12:20:01 AM all 0.74 0.00 0.34 0.38 98.54
12:30:02 AM all 1.09 0.00 0.28 0.10 98.53
12:40:01 AM all 0.76 0.00 0.21 0.03 99.00
12:50:01 AM all 1.25 0.00 0.32 0.03 98.40
01:00:01 AM all 0.80 0.00 0.24 0.03 98.92
...
.....
..
04:40:01 AM all 8.39 0.00 33.17 0.06 58.38
04:50:01 AM all 8.68 0.00 37.51 0.04 53.78
05:00:01 AM all 7.10 0.00 30.48 0.04 62.39
05:10:01 AM all 8.78 0.00 37.74 0.03 53.44
05:20:02 AM all 8.30 0.00 35.45 0.06 56.18
Average: all 3.09 0.00 9.14 0.09 87.68
Comparison of CPU utilization
The sar command writes to standard output the contents of selected cumulative activity counters in the operating system. The accounting system, based on the values in the count and interval parameters. For example display comparison of CPU utilization; 2 seconds apart; 5 times, use:# sar -u 2 5
Output (for each 2 seconds. 5 lines are displayed):
Linux 2.6.9-42.0.3.ELsmp (www1lab2.xyz.ac.in) 01/13/2007
05:33:24 AM CPU %user %nice %system %iowait %idle
05:33:26 AM all 9.50 0.00 49.00 0.00 41.50
05:33:28 AM all 16.79 0.00 74.69 0.00 8.52
05:33:30 AM all 17.21 0.00 80.30 0.00 2.49
05:33:32 AM all 16.75 0.00 81.00 0.00 2.25
05:33:34 AM all 14.29 0.00 72.43 0.00 13.28
Average: all 14.91 0.00 71.49 0.00 13.61
Where,
- -u 12 5 : Report CPU utilization. The following values are displayed:
- %user: Percentage of CPU utilization that occurred while executing at the user level (application).
- %nice: Percentage of CPU utilization that occurred while executing at the user level with nice priority.
- %system: Percentage of CPU utilization that occurred while executing at the system level (kernel).
- %iowait: Percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
- %idle: Percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.
To get multiple samples and multiple reports set an output file for the sar command. Run the sar command as a background process using.# sar -o output.file 12 8 >/dev/null 2>&1 &
Better use nohup command so that you can logout and check back report later on:# nohup sar -o output.file 12 8 >/dev/null 2>&1 &
All data is captured in binary form and saved to a file (data.file). The data can then be selectively displayed ith the sar command using the -f option.# sar -f data.file
2 comments:
Thanks a lot for the article.Really thank you! Will read on…
levitra bajer
Sorry for my bad english. Thank you so much for your good post. Your post helped me in my college assignment, If you can provide me more details please email me.
Post a Comment