pTools — 进程监控的一组工具
{
pTools是AIX 5.2中引进的System V UNIX 提供的一组极有用的工具,用于查看进程相关的信息。包括命令:
{
procwdx,
procfiles,
procflags,
proccred,
procmap,
procldd,
procsig,
procstack,
procstop,
procrun,
procwait,
proctree
}
procwdx, — 显示进程的当前工作目录。如:{
ccdd@root[/>]procwdx 725010
725010: /uniface/uniface8401/project/
}
procfiles — 显示该进程打开的所有文件描述字的信息。如:{
ccdd@root[/>]procfiles -n 725010
725010 : /uniface/uniface8401/bin/userver -drv=ANY -ust=ccddtest -dnp=TCP:+16000||| -asn=
Current rlimit: 2147483647 file descriptors
0: S_IFCHR mode:00 dev:10,4 ino:12349 uid:502 gid:501 rdev:2,2
O_RDONLY name:/dev/null
1: S_IFREG mode:0200 dev:169,1 ino:71335 uid:502 gid:501 rdev:0,0
O_WRONLY | O_APPEND size:0 name:/uniface/uniface8401/bin/nohup.out
2: S_IFREG mode:0200 dev:169,1 ino:71335 uid:502 gid:501 rdev:0,0
O_WRONLY | O_APPEND size:0 name:/uniface/uniface8401/bin/nohup.out
3: S_IFREG mode:0311 dev:169,1 ino:71267 uid:502 gid:501 rdev:0,0
O_WRONLY size:12060 name:/uniface/uniface8401/log/urouter.log
6: S_IFREG mode:0444 dev:10,13 ino:557059 uid:502 gid:501 rdev:8,33291
O_RDONLY size:17408 name:/oracle/app/oracle/product/9.2.0.6/rdbms/mesg/ocius.msb
8: S_IFREG mode:0444 dev:10,13 ino:557062 uid:502 gid:501 rdev:8,35315
O_RDONLY size:669696 name:/oracle/app/oracle/product/9.2.0.6/rdbms/mesg/oraus.msb
}
procflags — 显示/proc跟踪标记,包括等待和处理的信号量。如:{
ccdd@root[/>]procflags 725010
725010 : /uniface/uniface8401/bin/userver -drv=ANY -ust=ccddtest -dnp=TCP:+16000||| -asn=
data model = _LP64 flags = PR_FORK
/6779119: flags = PR_ASLEEP | PR_NOREGS
/6791413: flags = PR_ASLEEP | PR_NOREGS
/6787315: flags = PR_ASLEEP | PR_NOREGS
}
proccred — 显示拥有该进程的有效及实际用户 ID,及保留的用户和组ID(setuid及setgid)。如:{
ccdd@root[/>]proccred 725010
725010: e/r/suid=502 e/r/sgid=501
}
procmap — 显示进程地址空间。如:{
# procmap 725010
ccdd@root[/>]procmap 725010
725010 : /uniface/uniface8401/bin/userver -drv=ANY -ust=ccddtest -dnp=TCP:+16000||| -asn=
100000000 14K read/exec userver
1100009b7 1K read/write userver
9fffffff0000000 32K read/exec /usr/ccs/bin/usla64
9fffffff0008027 0K read/write /usr/ccs/bin/usla64
90000000140f238 3K read/exec /usr/lib/libc.a[aio_64.o]
8001000a012fc18 0K read/write /usr/lib/libc.a[aio_64.o]
9000000004b16c0 82K read/exec /usr/lib/libodm.a[shr_64.o]
8001000a0125a60 35K read/write /usr/lib/libodm.a[shr_64.o]
9000000009e0100 10424K read/exec /oracle/app/oracle/product/9.2.0.6/lib/libclntsh.a[shr.o]
8001000a007c270 672K read/write /oracle/app/oracle/product/9.2.0.6/lib/libclntsh.a[shr.o]
9000000009a0000 254K read/exec /uniface/uniface8401/lib/libuora44.a
8001000a0070538 44K read/write /uniface/uniface8401/lib/libuora44.a
900000000997000 35K read/exec /uniface/uniface8401/lib/libuserv.a
8001000a006eec0 1K read/write /uniface/uniface8401/lib/libuserv.a
900000000991000 21K read/exec /uniface/uniface8401/lib/libutcp10.a
8001000a006ce20 3K read/write /uniface/uniface8401/lib/libutcp10.a
900000000278000 12K read/exec /uniface/uniface8401/lib/libumwpsv10.a
8001000a006b8a8 0K read/write /uniface/uniface8401/lib/libumwpsv10.a
900000000276000 6K read/exec /uniface/uniface8401/lib/libusim.a
8001000a006a330 0K read/write /uniface/uniface8401/lib/libusim.a
900000000275480 2K read/exec /usr/lib/libC.a[shr3_64.o]
8001000a0069480 0K read/write /usr/lib/libC.a[shr3_64.o]
900000000274288 2K read/exec /usr/lib/libC_r.a[shr2_64.o]
8001000a0068288 0K read/write /usr/lib/libC_r.a[shr2_64.o]
90000000083fe00 1216K read/exec /usr/lib/libC_r.a[ansi_64.o]
8001000a003be00 173K read/write /usr/lib/libC_r.a[ansi_64.o]
9000000006d7000 1436K read/exec /uniface/uniface8401/lib/liburtl.a
8001000a0000100 232K read/write /uniface/uniface8401/lib/liburtl.a
9000000006b95e0 116K read/exec /usr/lib/libC.a[shrcore_64.o]
9001000a043a1e0 12K read/write /usr/lib/libC.a[shrcore_64.o]
90000000069f100 102K read/exec /usr/lib/libC.a[ansicore_64.o]
9001000a0430900 37K read/write /usr/lib/libC.a[ansicore_64.o]
90000000067caa0 135K read/exec /usr/lib/libC.a[shr_64.o]
9001000a042a8a0 19K read/write /usr/lib/libC.a[shr_64.o]
9000000004d3000 1513K read/exec /uniface/uniface8401/lib/libulib.a
9001000a03aef50 491K read/write /uniface/uniface8401/lib/libulib.a
900000000273000 0K read/exec /usr/lib/libdl.a[shr_64.o]
9001000a03ad000 0K read/write /usr/lib/libdl.a[shr_64.o]
90000000064e000 183K read/exec /usr/lib/libpthreads.a[shr_xpg5_64.o]
9001000a0321000 556K read/write /usr/lib/libpthreads.a[shr_xpg5_64.o]
900000000255268 2K read/exec /usr/lib/libcrypt.a[shr_64.o]
9001000a00c0748 0K read/write /usr/lib/libcrypt.a[shr_64.o]
900000000024260 2226K read/exec /usr/lib/libc.a[shr_64.o]
9001000a025e1e8 760K read/write /usr/lib/libc.a[shr_64.o]
9000000004c7000 44K read/exec /uniface/uniface8401/lib/libucall.a
9001000a031e610 6K read/write /uniface/uniface8401/lib/libucall.a
Total 20921K
}
procldd — 显示加载的动态进程列表。如:{
ccdd@root[/>]procldd 725010
725010 : /uniface/uniface8401/bin/userver -drv=ANY -ust=ccddtest -dnp=TCP:+16000||| -asn=
userver
/usr/ccs/bin/usla64
/usr/lib/libc.a[aio_64.o]
/usr/lib/libodm.a[shr_64.o]
/oracle/app/oracle/product/9.2.0.6/lib/libclntsh.a[shr.o]
/uniface/uniface8401/lib/libuora44.a
/uniface/uniface8401/lib/libuserv.a
/uniface/uniface8401/lib/libutcp10.a
/uniface/uniface8401/lib/libumwpsv10.a
/uniface/uniface8401/lib/libusim.a
/usr/lib/libC.a[shr3_64.o]
/usr/lib/libC_r.a[shr2_64.o]
/usr/lib/libC_r.a[ansi_64.o]
/uniface/uniface8401/lib/liburtl.a
/usr/lib/libC.a[shrcore_64.o]
/usr/lib/libC.a[ansicore_64.o]
/usr/lib/libC.a[shr_64.o]
/uniface/uniface8401/lib/libulib.a
/usr/lib/libdl.a[shr_64.o]
/usr/lib/libpthreads.a[shr_xpg5_64.o]
/usr/lib/libcrypt.a[shr_64.o]
/usr/lib/libc.a[shr_64.o]
/uniface/uniface8401/lib/libucall.a
}
procsig — 显示进程对各种信号量的处理。如:{
#ccdd@root[/>]procsig 725010
725010 : /uniface/uniface8401/bin/userver -drv=ANY -ust=ccddtest -dnp=TCP:+16000||| -asn=
HUP ignored RESETHAND
INT caught RESTART | SIGINFO
QUIT ignored 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 ignored RESTART | SIGINFO
ALRM ignored RESTART
TERM default
URG default
STOP default
TSTP ignored RESTART | SIGINFO
CONT default
CHLD ignored RESETHAND
TTIN default
TTOU default
IO default
XCPU default
XFSZ default
MSG default
WINCH default
PWR default
USR1 default
USR2 default
PROF default
DANGER default
VTALRM default
MIGRATE default
PRE default RESTART
VIRT default
ALRM1 default
WAITING caught RESTART
RECONFIG default
CPUFAIL default
KAP default
RETRACT default
SOUND default
SAK default
}
procstack — 显示进程中当前线程的堆栈中的符号名和十六进制地址。如:{
ccdd@root[/>]procstack 725010
725010 : /uniface/uniface8401/bin/userver -drv=ANY -ust=ccddtest -dnp=TCP:+16000||| -asn=
———- tid# 6779119 ———-
0x09000000009933f4 TCPreceive(0x4, 0x4, 0xfffffff, 0xffffc7c8) + ??
0x09000000009913ac UNWTCP(0x1) + 0x17c
0x09000000006e3cc0 unetgo(0x1, 0x1004eeb0) + 0x90
0x090000000027a004 dorcv(0x1, 0x1004eeb0, 0x200, 0x200) + 0xb8
0x0900000000279c78 recmsg(0x1, 0x1004eeb0, 0x0, 0x0, 0x200) + 0x190
0x0900000000278330 UMWPSV10(0xfffffff) + 0x100
0x090000000071f02c umwgo(0xfffffff, 0xfffff090) + 0x194
0x090000000071f3f8 urecmsg(0x1, 0x1004eeb0, 0x0, 0x0, 0x200) + 0x94
0x090000000099752c srvloop(0x1) + 0x198
0x0900000000997358 USERVERSTART(0x1, 0x1000dc90) + 0x128
0x0000000100002398 USRVMAIN(0x1) + 0x374
0x09000000004c8ed0 UMAIN(0x5, 0x5, 0xfffffff, 0xfffff500, 0xfffffff, 0xfffff468) + 0x6c
0x0000000100001f78 main(0x5, 0x5) + 0x34
0x0000000100000288 __start() + 0x90
———- tid# 6791413 ———-
0x09000000006589d0 _ptrgl() + ??
0x090000000065245c _pthread_body(?) + 0xbc
———- tid# 6787315 ———-
0x090000000002eec0 _ptrgl() + ??
0x090000000003ea1c nsleep(?, ?) + 0xac
0x090000000004a1fc sleep(?) + 0x58
0x0900000000526114 brokerThread(0x0) + 0x38
0x090000000065245c _pthread_body(?) + 0xbc
}
procstop — 将进程暂停。如:
procstop 725010
procrun — 启动用procstop停止的进程。如:
procrun 725010
procwait — 等待所指定的进程结束。如:
procwait 725010
proctree — 显示进程调用的树型结构。如:{
ccdd@root[/>]proctree 725010
671760 /uniface/uniface8401/bin/urouter start
725010 /uniface/uniface8401/bin/userver -drv=ANY -ust=ccddtest -dnp=TCP:+16000||| -asn=
}
}
如何查看某用户共启动了多少进程
#ps -ef|grep username|wc -l
备注:
这是利用wc -l统计行数的功能来对用户进程数的一个估计,并不是非常准确的值。
但完全可用于参考。
AIX环境如何找到活动最频繁的进程
{
1。下面命令输出中的’C’字段是一个进程的cpu-penalty值(0到120之间),值越大表明进程越活跃。
# ps alxw | sort +5 –n
2.显示前10个累计占用CPU时间的进程
#ps -e|head -n 1;ps -e|grep -v”TIME|0:”|sort +2b -3 -n -r|head -n 10
3。显示前10个当前占用CPU时间的进程
#ps -ef|head -n 1;ps -ef|grep -v”C|0:00″|sort +3b -4 -n -r|head -n 10
4。显示前10个占用CPU应用的进程
#ps gu|head -n 1;ps gu|grep -v”CPU|kproc”|sort +2b -3 -n -r|head -n 10
}
AIX查看是哪个进程占用某端口
{
1)netstat -Aan | grep 3306
最前面有一个地址,类似:f10000f301188b58 tcp4
2)用rmsock f10000f301188b58 tcpcb
如果占用了,会返回进程号。
3)kill那个进程
}
查看系统中某个端口正在被什么进程使用{
1. netstat -Aan|grep
找到该端口连接对应的PCB/ADDR和连接的协议类型。
2. 如果是tcp连接,则rmsock tcpcb
如果是udp连接,则rmsock inpcb
下面我们以telnet服务所使用的23号端口为例,说明该方法:
#netstat -Aan|grep 23
f1000200019ce398 tcp 0 0 *.23 *.* LISTEN
可以看到PCB/ADDR为f1000200019ce398,且协议类型为tcp。
#rmsock f1000200019ce398 tcpcb
The socket 0x19ce008 is being held by proccess 185006 (inetd).
命令报告该端口正在被inetd进程使用,PID为185006。
注意:rmsock命令需要root权限执行。如果我们以普通用户执行该命令,则会报告如下错误信息:
#rmsock f1000200019ce398 tcpcb
rmsock : Unable to read kernel address f1000200019ce398, errno = 13
rmsock : Unable to read kernel address 0000000000000000, errno = 13
error in opening /var/adm/ras/rmsock.logIt is not a socket
}
I think this is between the most significant information for me. And i am glad reading your article.