linux系统中我们需要查看某一进程占用服务器资源的消耗情况,应该如何去实现呢?下面我们分两步来告诉大家:
首先,我们需要查看这个进程的pid,假设pid为3007。
[root@localhost software]# top
- top - 15:42:20 up 49 min, 3 users, load average: 0.00, 0.02, 0.00
- Tasks: 339 total, 1 running, 338 sleeping, 0 stopped, 0 zombie
- Cpu(s): 0.0%us, 0.2%sy, 0.0%ni, 99.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
- Mem: 1938716k total, 884396k used, 1054320k free, 32140k buffers
- Swap: 4194296k total, 0k used, 4194296k free, 400232k cached
- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
- 231 root 20 0 0 0 0 S 0.3 0.0 0:00.65 scsi_eh_1
- 1925 www 20 0 98992 6276 3616 S 0.3 0.3 0:00.03 php-cgi
- 3007 mysql 20 0 1476m 89m 5072 S 0.3 4.7 0:42.67 mysqld
- 1 root 20 0 2900 1444 1224 S 0.0 0.1 0:03.15 init
- 2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
- 3 root RT 0 0 0 0 S 0.0 0.0 0:00.01 migration/0
- 4 root 20 0 0 0 0 S 0.0 0.0 0:00.02 ksoftirqd/0
- 5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
- 6 root RT 0 0 0 0 S 0.0 0.0 0:00.02 watchdog/0
- 7 root RT 0 0 0 0 S 0.0 0.0 0:00.01 migration/1
- 8 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/1
- 9 root 20 0 0 0 0 S 0.0 0.0 0:00.02 ksoftirqd/1
- 10 root RT 0 0 0 0 S 0.0 0.0 0:00.02 watchdog/1
- 11 root RT 0 0 0 0 S 0.0 0.0 0:00.01 migration/2
使用命令:
[root@localhost software]# top -p 3007
- top - 15:43:59 up 50 min, 3 users, load average: 0.00, 0.02, 0.00
- Tasks: 1 total, 0 running, 1 sleeping, 0 stopped, 0 zombie
- Cpu(s): 0.0%us, 0.0%sy, 0.0%ni, 99.9%id, 0.0%wa, 0.0%hi, 0.1%si, 0.0%st
- Mem: 1938716k total, 884272k used, 1054444k free, 32188k buffers
- Swap: 4194296k total, 0k used, 4194296k free, 400232k cached
- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
- 3007 mysql 20 0 1476m 89m 5072 S 0.0 4.7 0:42.69 mysqld
就可以实时查看这个进程的资源消耗情况了。