在linux中,我们通常要查看程序在运行时的各种信息,通常我们都用top命令直接查看。
当进程不多时,能一眼就能看出来。进程多时,便不好查看。所有针对特定进程检查就好多了。
shell
1
2
3
| function topn (){
top -p `pidof php-fpm | sed 's/[[:space:]]/,/g'`
}
|
1
2
3
| function topn (){
top `pidof ${1} | sed 's/\([0-9]* \)/-pid \1/g'`
}
|
例子
1
2
3
4
5
6
7
8
9
10
11
| Processes: 361 total, 3 running, 358 sleeping, 2017 threads 10:29:01
Load Avg: 3.39, 2.90, 2.68 CPU usage: 14.65% user, 13.0% sys, 72.34% idle SharedLibs: 116M resident, 36M data, 13M linkedit.
MemRegions: 345316 total, 2459M resident, 83M private, 972M shared. PhysMem: 7984M used (2504M wired), 207M unused.
VM: 2678G vsize, 1110M framework vsize, 91722115(0) swapins, 94352835(0) swapouts.
Networks: packets: 70749813/52G in, 28134076/12G out. Disks: 36491822/904G read, 15544943/625G written.
PID COMMAND %CPU TIME #TH #WQ #POR MEM PURG CMPRS PGRP PPID STATE BOOSTS %CPU_ME %CPU_OTHRS UID FAULT
97425 php-fpm 0.0 00:12.25 1 0 16 84K 0B 800K 97425 1 sleeping *0[1] 0.00000 0.00000 501 8278
33244 php-fpm 0.0 00:00.04 1 0 13 8192B 0B 6348K 97425 97425 sleeping *0[1] 0.00000 0.00000 501 2923
31121 php-fpm 0.0 00:00.07 1 0 13 8192B 0B 6980K 97425 97425 sleeping *0[1] 0.00000 0.00000 501 3390
27161 php-fpm 0.0 00:00.32 1 0 13 8192B 0B 8100K 97425 97425 sleeping *0[1] 0.00000 0.00000 501 8639
|