【AIX】AIX程式監控工具

xysoul_雲龍發表於2021-06-29

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 

procflags

    列印 /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  

STOP        default  

TSTP        default  

CONT        default  

CHLD        default  

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     default  RESTART

RECONFIG    default  

CPUFAIL     default  

KAP         default  

RETRACT     default  

SOUND       default  

SAK         default

procstack

檢視程式的堆疊。

$procstack 451098

open: Permission denied

Warning: executed in non-root mode

procstack cannot verify that /unix matches the running kernel.

Kernel symbols might not be validated.

451098: acsql

0x09000000000680f0  read(??, ??, ??) + 0x1c4

0x09000000000659cc  __filbuf(??) + 0x3fc

0x0900000000064f84  fgets(??, ??, ??) + 0x184

0x0000000100316898  CConnectMgr::ExecuteCmd()(0x1100726d0) + 0xb0

0x00000001002f3514  hbconnect(const char*)(0xfffffffffffaeac) + 0x74

0x000000010000bc28  main(0x100000001, 0xffffffffffff490) + 0xe74

0x0000000100000320  __start() + 0x98

procstack64

同procstack。是否只是支援64位程式?

$procstack64 451098

open: Permission denied

Warning: executed in non-root mode

procstack cannot verify that /unix matches the running kernel.

Kernel symbols might not be validated.

451098: acsql

0x09000000000680f0  read(??, ??, ??) + 0x1c4

0x09000000000659cc  __filbuf(??) + 0x3fc

0x0900000000064f84  fgets(??, ??, ??) + 0x184

0x0000000100316898  CConnectMgr::ExecuteCmd()(0x1100726d0) + 0xb0

0x00000001002f3514  hbconnect(const char*)(0xfffffffffffaeac) + 0x74

0x000000010000bc28  main(0x100000001, 0xffffffffffff490) + 0xe74

0x0000000100000320  __start() + 0x98

procstop

停止 PR_REQUESTED 事件的程式。什麼是“PR_REQUESTED 事件”?

$procstop 451098

procwait

    等待全部指定的程式終止。

$procwait 451098

procwdx

    檢視程式的當前工作目錄。

$procwdx 451098    

451098: /public/abp/abp_hss/AsynchronousCache.jammy/release/bin/


轉載:https://blog.csdn.net/mydriverc2/article/details/41979605

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29487349/viewspace-2778868/,如需轉載,請註明出處,否則將追究法律責任。

相關文章