分类: 系统运维
2013-09-27 11:31:11
AIX平台有一组功能强大的进程监控工具,利用它们可以进行进程监控、定位问题。不使用这些工具,直接从/proc/procssId目录下也可以获得这些信息。
e.g.
/proc/177022>ls -lt
total
16
-rw------- 1 root system 0 Feb 22 16:55
as
-r-------- 1 root system 128 Feb 22 16:55
cred
--w------- 1 root system 0 Feb 22 16:55
ctl
dr-x------ 1 root system 0 Feb 22 16:55
fd
dr-xr-xr-x 1 root system 0 Feb 22 16:55
lwp
-r-------- 1 root system 0 Feb 22 16:55
map
dr-x------ 1 root system 0 Feb 22 16:55
object
-r--r--r-- 1 root system 448 Feb 22 16:55
psinfo
-r-------- 1 root system 12288 Feb 22 16:55
sigact
-r-------- 1 root system 1520 Feb 22 16:55
status
-r--r--r-- 1 root system 0 Feb 22 16:55
sysent
lr-x------ 36 root system 0 Feb 22 13:35 cwd
这些工具存放在/usr/bin目录下,如下所示:
$which procstack
/usr/bin/procstack
这些工具名称为procXXXX。分别有:
$ls *proc* /usr/bin/
-r-xr-xr-x 1 bin bin 8282 Mar 13 2009 proccred
-r-xr-xr-x 1 bin bin 17340 Mar 13 2009 procfiles
-r-xr-xr-x 1 bin bin 14424 Mar 13 2009 procflags
-r-xr-xr-x 1 bin bin 10898 Mar 13 2009 procldd
-r-xr-xr-x 1 bin bin 11602 Mar 13 2009 procmap
-r-xr-xr-x 1 bin bin 8158 Mar 13 2009 procrun
-r-xr-xr-x 1 bin bin 8938 Mar 13 2009 procsig
-r-xr-xr-x 1 bin bin 20524 Mar 18 2009 procstack
-r-xr-xr-x 1 bin bin 21774 Mar 18 2009 procstack64
-r-xr-xr-x 1 bin bin 8578 Mar 13 2009 procstop
-r-xr-xr-x 1 bin bin 20022 Mar 13 2009 proctree
-r-xr-xr-x 1 bin bin 13216 Mar 13 2009 procwait
-r-xr-xr-x 1 bin bin 8754 Mar 13 2009 procwdx
三、用法示例
下面将一一认识一下这些命令。
proccred
显示进程所属的有效的、真实的、保留的用户ID和组ID。什么叫“有效的、真实的、保留的”?尚不大清楚。
$proccred 451098
451098: e/r/suid=205 e/r/sgid=1
procfiles
显示进程打开的文件描述符信息。该命令对于监控程序是否有句柄泄露非常有用。
$procfiles 451098
451098 : acsql
Current rlimit: 2147483647 file descriptors
0: S_IFCHR mode:00 dev:10,4 ino:9515 uid:205 gid:1 rdev:23,24
O_RDWR
1: S_IFCHR mode:00 dev:10,4 ino:9515 uid:205 gid:1 rdev:23,24
O_RDWR
2: S_IFCHR mode:00 dev:10,4 ino:9515 uid:205 gid:1 rdev:23,24
O_RDWR
3: S_IFREG mode:0600 dev:41,1 ino:538130 uid:205 gid:1 rdev:0,0
O_RDWR size:0
4: S_IFREG mode:0600 dev:41,1 ino:538130 uid:205 gid:1 rdev:0,0
O_RDWR size:0
5: S_IFREG mode:0600 dev:41,1 ino:538130 uid:205 gid:1 rdev:0,0
O_RDWR size:0
6: S_IFREG mode:0600 dev:41,1 ino:538130 uid:205 gid:1 rdev:0,0
O_RDWR size:0
7: S_IFREG mode:0600 dev:41,1 ino:538130 uid:205 gid:1 rdev:0,0
O_RDWR size:0
8: S_IFREG mode:0600 dev:41,1 ino:538130 uid:205 gid:1 rdev:0,0
O_RDWR size:0
9: S_IFREG mode:0600 dev:41,1 ino:538130 uid:205 gid:1 rdev:0,0
O_RDWR size:0
10: S_IFREG mode:0600 dev:41,1 ino:538130 uid:205 gid:1 rdev:0,0
O_RDWR size:0
11: S_IFREG mode:0600 dev:41,1 ino:538130 uid:205 gid:1 rdev:0,0
O_RDWR size:0
13: S_IFREG mode:0444 dev:0,0 ino:8416777 uid:205 gid:1 rdev:0,0
O_RDONLY size:448
打印 /proc 跟踪标志、暂挂和挂起信号,和指定进程中每个线程的其它 /proc 状态信息。显示进程的跟踪标志。加“-r”选项可以打印寄存器内容。
$procflags 451098
451098 : acsql
data model = _LP64 flags = PR_FORK
/872965: flags = PR_ASLEEP | PR_NOREGS
procldd
列出进程装入的动态库,包括使用 dlopen() 显式连接的共享对象。
$procldd 451098
451098 : acsql
acsql
/usr/ccs/bin/usla64
/usr/lib/libc.a[pse_64.o]
/usr/lib/liblvm.a[shr_64.o]
/usr/lib/libcfg.a[shr_64.o]
/usr/vacpp/lib/libC.a[shrcore_64.o]
/usr/vacpp/lib/libC.a[ansicore_64.o]
/usr/lib/libcrypt.a[shr_64.o]
/usr/lib/libxti.a[shr_64.o]
/usr/lib/libperfstat.a[shr_64.o]
/usr/lib/libodm.a[shr_64.o]
/usr/lib/libdl.a[shr_64.o]
/usr/vacpp/lib/libC.a[ansi_64.o]
/usr/vacpp/lib/libC.a[shr3_64.o]
/usr/vacpp/lib/libC.a[shr2_64.o]
/usr/vacpp/lib/libC.a[shr_64.o]
/usr/lib/libptools_ptr.a[shr_64.o]
/usr/lib/libpthreads.a[shr_xpg5_64.o]
/usr/lib/libc_r.a[shr_64.o]
/project/pb01/hss/lib/libACE.a[libACE.so.5]
/ora10/product/10.2.0/lib/libsqlplus.so
/project/pb01/hss/lib/libplatform.so
/ora10/product/10.2.0/lib/libclntsh.so
/project/pb01/hss/lib/librdbutil.so
procmap
打印进程的地址空间映射。
$procmap 451098
451098 : acsql
100000000 4304K read/exec acsql
110000cc3 374K read/write acsql
9fffffff0000000 44K read/exec /usr/ccs/bin/usla64
9fffffff000b30a 0K read/write /usr/ccs/bin/usla64
900000000873000 0K read/exec /usr/lib/libc.a[pse_64.o]
9001000a024c000 0K read/write /usr/lib/libc.a[pse_64.o]
9000000003d0880 484K read/exec /usr/lib/liblvm.a[shr_64.o]
9001000a0121ac8 135K read/write /usr/lib/liblvm.a[shr_64.o]
900000000369100 74K read/exec /usr/lib/libcfg.a[shr_64.o]
9001000a00f5e50 26K read/write /usr/lib/libcfg.a[shr_64.o]
900000000601a80 137K read/exec /usr/vacpp/lib/libC.a[shrcore_64.o]
9001000a0117280 13K read/write /usr/vacpp/lib/libC.a[shrcore_64.o]
90000000045f180 112K read/exec /usr/vacpp/lib/libC.a[ansicore_64.o]
9001000a010d380 37K read/write /usr/vacpp/lib/libC.a[ansicore_64.o]
900000000354280 2K read/exec /usr/lib/libcrypt.a[shr_64.o]
9001000a00d4760 0K read/write /usr/lib/libcrypt.a[shr_64.o]
900000005984e80 48K read/exec /usr/lib/libxti.a[shr_64.o]
9001000a0810b58 7K read/write /usr/lib/libxti.a[shr_64.o]
90000000044a080 83K read/exec /usr/lib/libperfstat.a[shr_64.o]
9001000a01d0818 9K read/write /usr/lib/libperfstat.a[shr_64.o]
900000000328400 85K read/exec /usr/lib/libodm.a[shr_64.o]
9001000a00d5d08 35K read/write /usr/lib/libodm.a[shr_64.o]
900000000863000 0K read/exec /usr/lib/libdl.a[shr_64.o]
9001000a036b000 0K read/write /usr/lib/libdl.a[shr_64.o]
90000000047c300 1552K read/exec /usr/vacpp/lib/libC.a[ansi_64.o]
9001000a01d5900 269K read/write /usr/vacpp/lib/libC.a[ansi_64.o]
9000000003558c8 2K read/exec /usr/vacpp/lib/libC.a[shr3_64.o]
9001000a01d38c8 0K read/write /usr/vacpp/lib/libC.a[shr3_64.o]
90000000065e6d0 2K read/exec /usr/vacpp/lib/libC.a[shr2_64.o]
9001000a01d46d0 0K read/write /usr/vacpp/lib/libC.a[shr2_64.o]
90000000037cb00 135K read/exec /usr/vacpp/lib/libC.a[shr_64.o]
9001000a011b900 19K read/write /usr/vacpp/lib/libC.a[shr_64.o]
900000006a4e080 18K read/exec /usr/lib/libptools_ptr.a[shr_64.o]
9001000a09d6cc8 5K read/write /usr/lib/libptools_ptr.a[shr_64.o]
900000000624000 228K read/exec /usr/lib/libpthreads.a[shr_xpg5_64.o]
9001000a0144000 558K read/write /usr/lib/libpthreads.a[shr_xpg5_64.o]
900000000042500 2966K read/exec /usr/lib/libc_r.a[shr_64.o]
9001000a0000788 844K read/write /usr/lib/libc_r.a[shr_64.o]
90000000ce9c100 2620K read/exec /project/pb01/hss/lib/libACE.a[libACE.so.5]
9001000a1636f0f 273K read/write /project/pb01/hss/lib/libACE.a[libACE.so.5]
9000000044ce000 17161K read/exec /ora10/product/10.2.0/lib/libsqlplus.so
9001000a024d590 957K read/write /ora10/product/10.2.0/lib/libsqlplus.so
90000000ce81000 107K read/exec /project/pb01/hss/lib/libplatform.so
9001000a162d448 10K read/write /project/pb01/hss/lib/libplatform.so
900000003447000 16814K read/exec /ora10/product/10.2.0/lib/libclntsh.so
9001000a0623808 993K read/write /ora10/product/10.2.0/lib/libclntsh.so
90000000ce55000 174K read/exec /project/pb01/hss/lib/librdbutil.so
9001000a1630930 20K read/write /project/pb01/hss/lib/librdbutil.so
Total 51758K
procrun
启动在 PR_REQUESTED 事件中停止的进程。 “PR_REQUESTED 事件”没有接触过。
$procrun 451098
451098 : ctl: Device busy
procsig
列出进程定义的信号操作。
$procsig 451098
451098 : acsql
HUP default
INT default
QUIT default RESTART
ILL default RESTART
TRAP default RESTART
ABRT default RESTART
EMT default RESTART
FPE default RESTART
KILL default RESTART
BUS default RESTART
SEGV default RESTART
SYS default RESTART
PIPE default
ALRM default
TERM default
URG default$procstack64 451098
open: Permission denied
Kernel symbols might not be validated.
451098: acsql
0x0000000100000320 __start() + 0x98
停止 PR_REQUESTED 事件的进程。什么是“PR_REQUESTED 事件”?
$procstop 451098
等待全部指定的进程终止。
$procwait 451098
查看进程的当前工作目录。
$procwdx 451098
451098: /public/abp/abp_hss/AsynchronousCache.jammy/release/bin/