1.top Use Rights: All users use: top [-] [D delay] [Q] [C] [s] [s] [i] [n] [b] Description: Instant display of the process of dynamic D: Change the display of the update speed, or in the chat-style command column (Interactive comm and) Press sq: There is no delay in the display speed, if the user is Superuser permissions, then top will be executed with the highest priority C: Toggle display mode, a total of two modes, one is to display the name of the execution file, the other is to display the full path and name S: Cumulative mode, The CPU time of the dead child process, which is completed or disappeared, is accumulated. S: Safe mode, cancels the conversational instruction, avoids potential crisis I: do not show any idle (idle) or useless (zombie) trip N: Number of updates, When finished, it will exit TOPB: Batch file mode, used with the "n" parameter, can be used to output the top result to the archive example: Display update 10 times after the exit; 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 another command about Linux traceroutewindows tracert two commands quite, trace network Route 2.vmstat as we The performance comparison of any system previously discussed is baseline based, and monitoring CPU performance is the above 3 points, running queues, CPU usage, and context switching. The following are some of the most common performance requirements for CPUs: 1. Do not run more than 3 for each CPU, for example, if it is a dual-core CPU, do 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 1procs-----------memory-------------Swap-------io------System------ CPU----r B swpd free buff cache si so bi bo in CS us sy ID wa0 0 104300 16800 95328 72200 0 0 5 26 7 14 4 1 95 00 0 104300 16800 95328 72200 0 0 0 24 1021 64 1 1 98 00 0 104300 16800 95328 72200 0 0 0 0 1009 1 1 98 0r indicates the size of the running queue, B indicates the number of threads in the block due to Io Wait, in represents the number of interrupts, CS indicates the number of context switches, US represents the user CPU time, SYS represents the system CPU time, WA represents the time that the CPU is idle due to IO waits, and the ID indicates the total time that the CPU is in idle state. Dstat can give the number of interrupts Per Device: # dstat-cip 1----total-cpu-usage--------INTERRUPTS------procs---usr sys idl Wai hiq siq| 169 185 |run Blk NEW6 1 91 2 0 0| 12 0 13 | 0 0 01 0 99 0 0 0| 0 0 6 | 0 0 00 0 100 0 0 0| 18 0 2 | 0 0 00 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/interruptscpu00: 1277238713 Io-apic-edge timer6:5 io-apic-edge floppy7:0 io-apic-edge parport08:1 io-apic-edge rtc9:1 IO-APIC-level ACP i14:6011913 Io-apic-edge ide015:15761438 io-apic-edge ide1169:26 io-apic-level Intel 82801ba-ich2185:16785489 IO-APIC- Level eth1193:0 Io-apic-level Uhci_hcd:usb1mpstat can show the health of each CPU, such as the system has 4 CPUs. We can see: # mpstat–p all 1Linux 2.4.21-20.ELSMP(Localhost.localdomain) 05/23/200605:17:31 pm CPU%user%nice%system%idle intr/s05:17:32 PM all 0.00 0.00 3.19 96.53 13. 2705:17:32 PM 0 0.00 0.00 0.00 100.00 0.0005:17:32 PM 1 1.12 0.00 12.73 86.15 13.2705:17:32 PM 2 0.00 0.00 0.00 100.00 0.0 005:17:32 PM 3 0.00 0.00 0.00 100.00 0.00 In summary, CPU performance monitoring includes the following aspects: Check the running queue of the system, and ensure that each CPU runs on a queue that is not greater than 3. Ensure that the CPU usage distribution satisfies 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 59 0 0:08.2 7 0.2% xsun/1 15497 jtd 48M 41M sleep 0 0:08.26 0.1% adeptedit/1 328 root 2856K 2600K sleep 58 0 0:0 0.00 0.0% MIBIISA/11 1979 JTD 1568K 1352K sleep 0 0:00.00 0.0% CSH/1 1977 JTD 7256K 5512K sleep 49 0 0: 00.00 0.0% dtterm/1 192 root 3680K 2856K sleep 58 0 0:00.36 0%AUTOMOUNTD/5 1845 JTD 24M 22M sleep 0 0:00.29 0.0% dtmail/11 1009 JTD 9864K 8384K sleep 49 0 0:00.59 0.0% DTWM/8 root 1640K 704K sleep 0 0:01.16 0.0% in.routed/1 0 daemon 2704K 1944K sleep 58-0:00. 0.0% STATD/4 145 root 2120K 1520K sleep 0 0:00.00 0.0% ypbind/1 181 root 1864K 1336K sleep 51 0 0: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 . xx 0.0% Keyserv/4projid 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 the current operation on For various statistics on the processes and tasks of the row, 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 JT D 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 81 04K Sleep 0 0:00:27 0.0% dtwm/5 29010 jtd 5144K 4664K cpu0 0 0:00:00 0.0% prstat/1 $ root 3096K 1 024K Sleep 0 0:00:00 0.0% lpsched/1 161 root 2120K 1600K sleep 0 0:00:00 0.0% LOCKD/2 the root 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 Roo T 1664K 672K sleep 0 0:00:03 0.0% in.rdisc/1taskid 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% Gro Up.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 note the –-j and-t options cannot be used together.
Linux View CPU usage