A few common commands, some nice explanations
http://blog.csdn.net/wengpingbo/article/details/6302058
1.top
Usage rights: All users
Mode of use: Top [-] [D delay] [Q] [C] [s] [s] [i] [n] [b]
Description: Instant display of process dynamics
D: Change the update speed of the display, or press s in the chat command column (interactive command)
Q: There is no delay in the display speed, if the user has Superuser permissions, then top will be executed with the highest precedence
C: Toggle display mode, a total of two modes, one is to display the name of the execution file only, the other is to display the full path and name S: Cumulative mode, will be completed or disappeared sub-stroke (dead child process) CPU time accumulated
S: Safe mode, cancel conversational instruction, avoid potential crisis
I: Do not display any idle (idle) or useless (zombie) travel
N: The number of updates that will exit the top after completion
B: Batch mode, used with "n" parameter, can be used to output top results in the file
Example:
Show Update 10 times after exiting;
Top-n 10
The user will not be able to use the conversational instruction to command the trip:
Top-s
Enter the results of the update display two times into the file named Top.log:
Top-n 2-b < Top.log
Attach a command brief introduction to Linux traceroutewindows tracert two commands quite, trace network routing
2.vmstat
As the performance comparison of any system we discussed earlier is baseline based, and monitoring CPU performance is the above 3 points, running queue, CPU utilization, and context switching. The following are some of the most common performance requirements for CPUs:
1. For each CPU to run the queue do not exceed 3, for example, if the dual-core CPU should not exceed 6;
2. If the CPU is running at full load, the following distribution should be met
A) User time:65%~70%
b) System time:30%~35%
c) idle:0%~5%
3. Mpstat
For context switches to be combined with CPU usage, a large number of context switches are acceptable if CPU usage satisfies the above distribution.
Common monitoring tools are: Vmstat, Top,dstat and Mpstat.
# vmstat 1
procs-----------Memory-------------Swap-------io------System------CPU----
R b swpd free buff cache si so bi bo in CS US sy ID WA
0 0 104300 16800 95328 72200 0 0 5 26 7 14 4 1 95 0
0 0 104300 16800 95328 72200 0 0 0 24 1021 64 1 1 98 0
0 0 104300 16800 95328 72200 0 0 0 0 1009 59 1 1 98 0
R indicates the size of the running queue,
b indicates the number of threads in the block due to IO waiting,
In indicates the number of interrupts,
CS indicates the number of context switches,
The US represents the user's CPU time,
SYS indicates system CPU time,
WA represents the time that the CPU is idle due to IO wait,
The ID indicates the total amount of time the CPU is in an idle state.
Dstat can give the number of interrupts that are generated by each device:
# dstat-cip 1
----total-cpu-usage--------INTERRUPTS------procs---
USR sys IDL Wai hiq siq| 169 185 |run Blk NEW
6 1 91 2 0 0| 12 0 13 | 0 0 0
1 0 99 0 0 0| 0 0 6 | 0 0 0
0 0 100 0 0 0| 18 0 2 | 0 0 0
0 0 100 0 0 0| 0 0 3 | 0 0 0
We can see there are 3 device numbers 15,169 and 185. The relationship between the device name and the device number we can refer to the file/proc/interrupts, where 185 represents the NIC eth1.
# cat/proc/interrupts
CPU0
0:1277238713 Io-apic-edge Timer
6:5 Io-apic-edge Floppy
7:0 Io-apic-edge parport0
8:1 Io-apic-edge RTC
9:1 Io-apic-level ACPI
14:6011913 Io-apic-edge ide0
15:15761438 Io-apic-edge Ide1
169:26 Io-apic-level Intel 82801BA-ICH2
185:16785489 Io-apic-level eth1
193:0 Io-apic-level UHCI_HCD:USB1
The mpstat can show the health of each CPU, such as a system with 4 CPUs. We can see:
# mpstat–p All 1
Linux 2.4.21-20.ELSMP (Localhost.localdomain) 05/23/2006
05:17:31 PM CPU%user%nice%system%idle intr/s
05:17:32 PM All 0.00 0.00 3.19 96.53 13.27
05:17:32 PM 0 0.00 0.00 0.00 100.00 0.00
05:17:32 PM 1 1.12 0.00 12.73 86.15 13.27
05:17:32 PM 2 0.00 0.00 0.00 100.00 0.00
05:17:32 PM 3 0.00 0.00 0.00 100.00 0.00
In summary, CPU performance monitoring includes the following:
Check the system's running queue to ensure that each CPU runs at a queue of no more than 3.
Ensure that the CPU usage distribution meets the 70/30 principle (user 70%, System 30%).
If the system time is too long, it may be because of frequent scheduling and changing priorities.
The CPU bound process is always punished (lower priority) and the IO bound process is always rewarded (higher priority).
4.prstat command
To display various statistics about the processes and projects currently running on your system, use the Prstat command with the -j option:
%prstat-j PID USERNAME SIZE RSS State PRI nice time CPU PROCESS/NLWP 21634 jtd 5512K 4848K cpu0 0 0:00.00 0.3% PRSTAT/1 324 root 29M 75M sleep 0 0:08.27 0.2% XSUN/1 15497 jtd 48M 41M sleep 0 0:08.26 0.1% ADEPTEDIT/1 328 root 2856K 2600K sleep 0 0:00.00 0.0% MIBIISA/11 1979 JTD 1568K 1352K sleep 0 0:00.00 0.0% CSH/1 1977 JTD 7256K 5512K sleep 0 0:00.00 0.0% DTTERM/1 192 root 3680K 2856K sleep 0 0:00.36 0.0% AUTOMOUNTD/5 1845 JTD 24M 22M sleep 0 0:00.29 0.0% DTMAIL/11 1009 JTD 9864K 8384K sleep 0 0:00.59 0.0% DTWM/8 Root 1640K 704K sleep 0 0:01.16 0.0% IN.ROUTED/1 Daemon 2704K 1944K sleep 0 0:00.00 0.0% STATD/4 145 root 2120K 1520K sleep 0 0:00.00 0.0% YPBIND/1 181 root 1864K 1336K sleep 0 0:00.00 0.0% LOCKD/1 173 root 2584K 2136K sleep 0 0:00.00 0.0% INETD/1 135 root 2960K 1424K sleep 0 0 0:00.00 0.0% KEYSERV/4 ProjId nproc SIZE RSS MEMORY time CPU PROJECT 400M 271M 68% 0:11.45 0.4% booksite 0 113M 129M 32% 0:10.46 0.2% System total:87 processes, 205 lwps, Load averages:0.05, 0.02, 0.02 |
To display various statistics about the processes and tasks currently running on the system, use the Prstat command with the- t option:
%prstat-t PID USERNAME SIZE RSS State PRI nice time CPU PROCESS/NLWP 23023 Root 26M 20M sleep 0 0:03:18 0.6% XSUN/1 23476 jtd 51M 45M sleep 0 0:04:31 0.5% ADEPTEDIT/1 23432 jtd 6928K 5064K sleep 0 0:00:00 0.1% DTTERM/1 28959 jtd 26M 18M sleep 0 0:00:18 0.0% NETSCAPE.BIN/1 23116 jtd 9232K 8104K sleep 0 0:00:27 0.0% DTWM/5 29010 jtd 5144K 4664K cpu0 0 0:00:00 0.0% PRSTAT/1 Root 3096K 1024K sleep 0 0:00:00 0.0% LPSCHED/1 161 root 2120K 1600K sleep 0 0:00:00 0.0% LOCKD/2 5888K 4248K sleep 0 0:03:10 0.0% AUTOMOUNTD/3 Root 2120K 1408K sleep 0 0:00:00 0.0% YPBIND/1 162 Daemon 2504K 1936K sleep 0 0:00:00 0.0% STATD/2 146 root 2560K 2008K sleep 0 0:00:00 0.0% INETD/1 122 root 2336K 1264K sleep 0 0:00:00 0.0% KEYSERV/2 119 Root 2336K 1496K sleep 0 0:00:02 0.0% RPCBIND/1 104 Root 1664K 672K sleep 0 0:00:03 0.0% IN.RDISC/1 TASKID nproc SIZE RSS MEMORY time CPU PROJECT 222 229M 161M 44% 0:05:54 0.6% group.staff 223 1 26M 20M 5.3% 0:03:18 0.6% group.staff 1 61M 33M 8.9% 0:00:31 0.0% group.staff 1 85M 53M 14% 0:03:33 0.0% System total:65 processes, 154 lwps, load averages:0.04, 0.05, 0.06 |
Reprint-commands for viewing CPU usage under Linux