ps
ps命令有很多种用法,最常见的是 ps auxfww
[root@mio-254 ~]# ps auxfww USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 2 0.0 0.0 0 0 ? S Aug24 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S Aug24 0:00 \_ [migration/0] root 4 0.0 0.0 0 0 ? S Aug24 0:04 \_ [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S Aug24 0:00 \_ [migration/0] root 6 0.0 0.0 0 0 ? S Aug24 0:01 \_ [watchdog/0] qemu 3127 0.0 1.1 1484076 365524 ? Sl Aug24 17:15 /usr/libexec/qemu-kvm -name MIO-99-NFS-TIME-DNS -S -M rhel6.5.0 -enable-kvm -m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 833e70c4-1b2f-04f6-4612-d478d496a748 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/MIO-99-NFS-TIME-DNS.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/MIO-99-NFS-TIME-DNS.img,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=24 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:e2:ed:a6,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 qemu 3164 0.1 1.3 2612524 449604 ? Sl Aug24 32:46 /usr/libexec/qemu-kvm -name MIO-80-MYSQL -S -M rhel6.5.0 -enable-kvm -m 2048 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 53f35fd3-e7bb-ca7c-c06a-60795b155400 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/MIO-80-MYSQL.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/MIO-80-MYSQL.img,if=none,id=drive-virtio-disk0,format=raw,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=25 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ad:4f:62,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -vnc 127.0.0.1:2 -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
这样,能以树形式显示进程间的父子关系,又能比pstree多出CPU和MEM等其他性能数据
什么是VSZ和RSS?
需要注意的是VSZ和RSS
VSZ(Virtual Memory Size):指进程可以占用的内存地址空间大小
RSS(Resident Set Size):指实际占用内存地址空间大小
RSS包含了共享库占用的内存大小,我们可以通过pmap命令看到进程调用的各种库占用的内存
[root@mio-254 ~]# pmap -d 29248 29248: /usr/libexec/qemu-kvm -name MIO-03-PYTEST -S -M rhel6.5.0 -enable-kvm -m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid 14f723fa-8806-0d9a-3f52-143258006d44 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/MIO-03-PYTEST.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/var/lib/libvirt/images/MIO-03-PYTEST.img,if=none,id=drive-virtio-disk0,for Address Kbytes Mode Offset Device Mapping 00007f0c761fd000 4 ----- 0000000000000000 000:00000 [ anon ] 00007f0c761fe000 10240 rw--- 0000000000000000 000:00000 [ anon ] 00007f0c775ff000 4 ----- 0000000000000000 000:00000 [ anon ] 00007f0c77600000 10240 rw--- 0000000000000000 000:00000 [ anon ] 00007f0c78000000 132 rw--- 0000000000000000 000:00000 [ anon ] 00007f0c78021000 65404 ----- 0000000000000000 000:00000 [ anon ] 00007f0c7db32000 1204 rw--- 0000000000000000 000:00000 [ anon ] 00007f0c7dc5f000 48 r-x-- 0000000000000000 0fd:00000 libdigestmd5.so.2.0.23 00007f0c7dc6b000 2044 ----- 000000000000c000 0fd:00000 libdigestmd5.so.2.0.23 00007f0c7de6a000 4 r---- 000000000000b000 0fd:00000 libdigestmd5.so.2.0.23 00007f0c7de6b000 4 rw--- 000000000000c000 0fd:00000 libdigestmd5.so.2.0.23