名称:
pmap - report memory map of a process(查看进程的内存映像信息)
用法
pmap [ -x | -d ] [ -q ] pids...
pmap -V
选项含义
-x extended Show the extended format. 显示扩展格式
-d device Show the device format. 显示设备格式
-q quiet Do not display some header/footer lines. 不显示头尾行
-V show version Displays version of program. 显示版本
扩展格式和设备格式域:
Address: start address of map 映像起始地址
Kbytes: size of map in kilobytes 映像大小
RSS: resident set size in kilobytes 驻留集大小
Dirty: dirty pages (both shared and private) in kilobytes 脏页大小
Mode: permissions on map 映像权限: r=read, w=write, x=execute, s=shared, p=private (copy on write)
Mapping: file backing the map , or '[ anon ]' for allocated memory, or '[ stack ]' for the program stack. 映像支持文件,[anon]为已分配内存 [stack]为程序堆栈
Offset: offset into the file 文件偏移
Device: device name (major:minor) 设备名
pmap -d 1
pmap -d 1 -q 不显示头尾
[root@C44 ~]# while true; do pmap -d 3066 | tail -1; sleep 2; done 循环显示进程3066的设备格式的最后1行,间隔2秒,
最后一行的值
mapped 表示该进程映射的虚拟地址空间大小,也就是该进程预先分配的虚拟内存大小,即ps出的vsz
writeable/private 表示进程所占用的私有地址空间大小,也就是该进程实际使用的内存大小
shared 表示进程和其他进程共享的内存大小
[root@-shiyan bin]# pmap -x
: sshd: root@pts/
Address Kbytes RSS Dirty Mode Mapping
00007f979d216000 rw--- [ anon ]
00007f979d3a0000 rw-s- zero (deleted)
00007f979d4e0000 r-x-- pam_limits.so
00007f979d4e4000 ----- pam_limits.so
00007f979d6e3000 r---- pam_limits.so
00007f979d6e4000 rw--- pam_limits.so
00007f979d6e5000 r-x-- pam_keyinit.so [root@-shiyan bin]# pmap -d
: sshd: root@pts/
Address Kbytes Mode Offset Device Mapping
00007f979d216000 rw--- : [ anon ]
00007f979d3a0000 rw-s- : zero (deleted)
00007f979d4e0000 r-x-- 0fd: pam_limits.so
00007f979d4e4000 ----- 0fd: pam_limits.so
[root@221-comecs ~]# watch -d -n 1 'ss -n|grep 10001'
15:19:16 23 ~:#uptime
15:28:15 up 38 days, 3:57, 2 users, load average: 0.00, 0.00, 0.00
snice与skill是一对,pgrep与pkill是一对
pgrep, pkill - look up or signal processes based on name and other attributes
pgrep根据用户名,命令名或者其它属性过滤出pid,非常方便,pkill发送相应的信号
[root@109-com1 bin]# pgrep F
26195
root 26195 1 4 Jul23 pts/2 01:00:28 /usr/local/ps/bin/FLTService
15:31:39 25 ~:#ldd /usr/bin/uptime
linux-vdso.so.1 => (0x00007fff291ff000)
libproc-3.2.8.so => /lib64/libproc-3.2.8.so (0x00007f2a52250000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2a51ebc000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2a5247a000)
15:31:52 26 ~:#ldd /usr/bin/w
linux-vdso.so.1 => (0x00007fffd8326000)
libproc-3.2.8.so => /lib64/libproc-3.2.8.so (0x00007f4f54789000)
libc.so.6 => /lib64/libc.so.6 (0x00007f4f543f5000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4f549b3000)
15:32:15 27 ~:#ldd /usr/bin/vmstat
linux-vdso.so.1 => (0x00007fff029ff000)
libproc-3.2.8.so => /lib64/libproc-3.2.8.so (0x00007fbf227d6000)
libc.so.6 => /lib64/libc.so.6 (0x00007fbf22442000)
/lib64/ld-linux-x86-64.so.2 (0x00007fbf22a00000)
procps相关工具都调用同一个库
[oracle@localhost ~]$ rpm -ql procps
/bin/ps
/lib64/libproc-3.2.8.so
/lib64/libproc.so
/sbin/sysctl
/usr/bin/free
/usr/bin/pgrep
/usr/bin/pkill
/usr/bin/pmap
/usr/bin/pwdx
/usr/bin/skill
/usr/bin/slabtop
/usr/bin/snice
/usr/bin/tload
/usr/bin/top
/usr/bin/uptime
/usr/bin/vmstat
/usr/bin/w
/usr/bin/watch