The mpstat command is used for checking the cpu usage in Linux or monitor the Linux system performance. It gives the processor statistics. If your system has multiple processor cores, you can use the mpstat command to monitor each individual core. The mpstat command provides the same CPU utilization statistics as vmstat, but mpstat gives the statistics out on a per processor basis.
You can see example as below for CPU performance monitoring linux:
{desktop002:root} mpstat
CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl
0 319 0 5 340 101 121 0 15 4 0 339 1 1 0 99
1 113 0 2 94 16 81 0 7 4 0 113 0 1 0 99
2 156 0 2 74 18 61 0 5 3 0 123 0 0 0 100
3 154 0 2 66 22 61 0 3 3 0 169 0 0 0 100
4 2156 0 3 51 32 73 0 28 5 0 962 1 2 0 97
5 31 0 2 18 1 16 0 4 3 0 47 0 0 0 100
6 11 0 2 19 2 14 0 4 2 0 24 0 0 0 100
7 9 0 2 18 2 14 0 4 2 0 24 0 0 0 100
8 265 0 1 40 11 42 0 4 2 0 153 0 0 0 100
9 115 0 2 36 8 31 0 3 2 0 81 0 0 0 100
10 72 0 1 37 7 40 0 2 2 0 118 0 0 0 100
11 235 0 1 29 6 35 0 3 2 0 163 0 0 0 100
12 8 0 2 18 3 12 0 4 2 0 16 0 0 0 100
13 6 0 2 16 1 12 0 4 2 0 13 0 0 0 100
14 6 0 2 17 1 13 0 4 2 0 19 0 0 0 100
15 6 0 2 16 1 12 0 4 2 0 14 0 0 0 100
{desktop002:root}
|
mpstat command's general format to get output:
$ mpstat <interval> <count>
|
You can see the columns and its meaning as follows:
minf minor faults.
mjf major faults.
Xcal inter-processor cross calls
Intr interrupts
ithr interrupts as threads (not counting clock interrupt)
csw context switches
icsw involuntary context switches
migr thread migrations (to another processor)
smtx spins on mutexes (lock not acquired on first try)
srw spins on readers/writer locks (lock not acquired on first try)
syscl system calls
usr percent user time
sys percent system time
wt the I/O wait time is no longer calculated as a percentage of CPU time, and this statistic will always return zero.
idl percent idle time
mpstat command examples:
If you want to get 7 reports at interval of 60 seconds (1 minute) then use following command:
{desktop004:root} mpstat 60 7
|
You will get CPU usage 7 reports on every 1 minute interval. Run this background, and redirect its output to one file.
0 comments:
Post a Comment