[20190402]跟蹤vmstat.txt

lfree發表於2019-04-02

[20190402]跟蹤vmstat.txt


$ strace -e open vmstat 1 10

open("/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/tls/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/tls/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/u01/app/oracle/product/11.2.0.4/dbhome_1/oracm/lib/tls/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/u01/app/oracle/product/11.2.0.4/dbhome_1/oracm/lib/tls/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/u01/app/oracle/product/11.2.0.4/dbhome_1/oracm/lib/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/u01/app/oracle/product/11.2.0.4/dbhome_1/oracm/lib/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib/tls/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib/tls/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/lib/tls/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/lib/tls/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/lib/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/lib/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/local/lib/tls/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/local/lib/tls/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/local/lib/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/usr/local/lib/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib64/tls/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib64/tls/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib64/x86_64/libproc-3.2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib64/libproc-3.2.7.so", O_RDONLY) = 3

open("/u01/app/oracle/product/11.2.0.4/dbhome_1/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib/libc.so.6", O_RDONLY)        = 3

open("/usr/lib/libc.so.6", O_RDONLY)    = -1 ENOENT (No such file or directory)

open("/usr/local/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)

open("/lib64/libc.so.6", O_RDONLY)      = 3

open("/proc/stat", O_RDONLY)            = 3

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------

 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st

open("/proc/meminfo", O_RDONLY)         = 3

open("/proc/stat", O_RDONLY)            = 4

open("/proc/vmstat", O_RDONLY)          = 5

 0  0      0 119228960 273596 9947928    0    0     3     3    0    0  0  1 99  0  0

 0  0      0 119228944 273596 9947928    0    0     0     4 1180 2131  0  0 100  0  0

 0  0      0 119228928 273596 9947928    0    0     0     0 1129 2102  0  0 100  0  0

 0  0      0 119229056 273596 9947928    0    0     0     0 1130 2097  0  0 100  0  0

 0  0      0 119229056 273596 9947928    0    0     0     0 1148 2152  0  0 100  0  0

 0  0      0 119228912 273596 9947928    0    0     0     0 1139 2103  0  0 100  0  0

 0  0      0 119229168 273596 9947928    0    0     0     0 1122 2101  0  0 100  0  0

 0  0      0 119229176 273596 9947928    0    0     0     0 1124 2102  0  0 100  0  0

 0  0      0 119229176 273596 9947928    0    0     0     0 1182 2155  0  0 100  0  0

 0  0      0 119229296 273596 9947928    0    0     0     0 1138 2094  0  0 100  0  0


--//從open開啟的檔案控制程式碼看,可以發現開啟/proc/stat,/proc/meminfo,/proc/stat,/proc/vmstat來構建輸出資訊.

--//聯想到oracle也有一個檢視記錄v$osstat記錄os相關資訊.

SYS@book> select * from v$bgprocess where NAME like 'MMNL';

PADDR              PSERIAL# NAME                 DESCRIPTION                                 ERROR

---------------- ---------- -------------------- ---------------------------------------- --------

0000000086205CC0          1 MMNL                 Manageability Monitor Process 2          0


--//收集資訊主要包括mmnl程式.


$ ps -ef | grep ora_mmnl_boo[k]

oracle   56355     1  0 08:38 ?        00:00:13 ora_mmnl_book


$ strace -fTtt -e open -p 56355

Process 56355 attached - interrupt to quit

17:26:43.091236 open("/proc/mounts", O_RDONLY) = 12 <0.000065>

17:26:43.092005 open("/proc/stat", O_RDONLY) = 12 <0.000038>

17:26:43.092729 open("/proc/cpuinfo", O_RDONLY) = 12 <0.000028>

17:26:43.094959 open("/proc/mounts", O_RDONLY) = 13 <0.000046>

17:26:43.095541 open("/proc/cpuinfo", O_RDONLY) = 12 <0.000031>

17:26:43.097678 open("/proc/mounts", O_RDONLY) = 13 <0.000039>

17:26:43.098220 open("/proc/loadavg", O_RDONLY) = 12 <0.000030>

17:26:43.098623 open("/proc/stat", O_RDONLY) = 12 <0.000029>

17:26:43.099790 open("/proc/mounts", O_RDONLY) = 12 <0.000046>

17:26:43.100255 open("/proc/stat", O_RDONLY) = 12 <0.000035>


17:26:58.115820 open("/proc/mounts", O_RDONLY) = 12 <0.000060>

17:26:58.116411 open("/proc/stat", O_RDONLY) = 12 <0.000035>

17:26:58.117141 open("/proc/cpuinfo", O_RDONLY) = 12 <0.000033>

17:26:58.119449 open("/proc/mounts", O_RDONLY) = 13 <0.000047>

17:26:58.120029 open("/proc/cpuinfo", O_RDONLY) = 12 <0.000031>

17:26:58.122269 open("/proc/mounts", O_RDONLY) = 13 <0.000048>

17:26:58.122855 open("/proc/loadavg", O_RDONLY) = 12 <0.000031>

17:26:58.123257 open("/proc/stat", O_RDONLY) = 12 <0.000030>


17:27:13.138885 open("/proc/mounts", O_RDONLY) = 12 <0.000063>

17:27:13.139463 open("/proc/stat", O_RDONLY) = 12 <0.000042>

17:27:13.140179 open("/proc/cpuinfo", O_RDONLY) = 12 <0.000030>

17:27:13.142463 open("/proc/mounts", O_RDONLY) = 13 <0.000046>

17:27:13.143043 open("/proc/cpuinfo", O_RDONLY) = 12 <0.000031>

17:27:13.145260 open("/proc/mounts", O_RDONLY) = 13 <0.000043>

17:27:13.145852 open("/proc/loadavg", O_RDONLY) = 12 <0.000030>

17:27:13.146257 open("/proc/stat", O_RDONLY) = 12 <0.000030>


17:27:19.152746 open("/proc/56321/stat", O_RDONLY) = 12 <0.000041>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 $ ps -ef | grep 5632[1]

oracle   56321     1  0 08:38 ?        00:00:04 ora_pmon_book

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

17:27:28.161875 open("/proc/mounts", O_RDONLY) = 12 <0.000062>

17:27:28.162470 open("/proc/stat", O_RDONLY) = 12 <0.000036>

17:27:28.163213 open("/proc/cpuinfo", O_RDONLY) = 12 <0.000032>

17:27:28.165590 open("/proc/mounts", O_RDONLY) = 13 <0.000045>

17:27:28.166170 open("/proc/cpuinfo", O_RDONLY) = 12 <0.000031>

17:27:28.168404 open("/proc/mounts", O_RDONLY) = 13 <0.000045>

17:27:28.168971 open("/proc/loadavg", O_RDONLY) = 12 <0.000037>

17:27:28.169380 open("/proc/stat", O_RDONLY) = 12 <0.000035>

17:27:43.186295 open("/proc/mounts", O_RDONLY) = 12 <0.000074>

17:27:43.186846 open("/proc/stat", O_RDONLY) = 12 <0.000040>

17:27:43.187613 open("/proc/cpuinfo", O_RDONLY) = 12 <0.000034>

17:27:43.189873 open("/proc/mounts", O_RDONLY) = 13 <0.000048>

17:27:43.190499 open("/proc/cpuinfo", O_RDONLY) = 12 <0.000032>

17:27:43.192716 open("/proc/mounts", O_RDONLY) = 13 <0.000040>

17:27:43.193310 open("/proc/loadavg", O_RDONLY) = 12 <0.000031>

17:27:43.193736 open("/proc/stat", O_RDONLY) = 12 <0.000030>

17:27:43.194922 open("/proc/mounts", O_RDONLY) = 12 <0.000045>

17:27:43.195453 open("/proc/stat", O_RDONLY) = 12 <0.000031>

^CProcess 56355 detached


--//實際上oracle也非常類似,ora_mmnl_book程式大約每15秒讀取相關/proc目錄的虛擬檔案,收集相關資訊.

--//實際上oracle許多監測工具都非常類似,相關/proc目錄的虛擬檔案,收集相關資訊.

$ strace -fTr -e open dstat 2 10 1>/dev/null

...

    0.000112 open("/usr/lib64/python2.4/getopt.pyc", O_RDONLY) = 4 <0.000020>

     0.000595 open("/proc/uptime", O_RDONLY) = 3 <0.000032>

     0.000361 open("/proc/stat", O_RDONLY) = 3 <0.000029>

     0.002903 open("/proc/diskstats", O_RDONLY) = 4 <0.000029>

     0.002209 open("/proc/net/dev", O_RDONLY) = 5 <0.000048>

     0.000601 open("/proc/vmstat", O_RDONLY) = 6 <0.000028>

     2.000639 --- SIGALRM (Alarm clock) @ 0 (0) ---

     2.000584 --- SIGALRM (Alarm clock) @ 0 (0) ---

     2.000375 --- SIGALRM (Alarm clock) @ 0 (0) ---

     2.000302 --- SIGALRM (Alarm clock) @ 0 (0) ---

     2.000446 --- SIGALRM (Alarm clock) @ 0 (0) ---

     2.000549 --- SIGALRM (Alarm clock) @ 0 (0) ---

     2.000343 --- SIGALRM (Alarm clock) @ 0 (0) ---

     2.000534 --- SIGALRM (Alarm clock) @ 0 (0) ---

     2.000448 --- SIGALRM (Alarm clock) @ 0 (0) ---

     2.000365 --- SIGALRM (Alarm clock) @ 0 (0) ---


# strace -f -e open -o /tmp/x1.txt smem -tk  -U oracle -P "ora_" 1>/dev/null


--//檢視/tmp/x1.txt

...

63962 open("/proc", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 3

63962 open("/proc/1/cmdline", O_RDONLY) = 3

63962 open("/proc/2/cmdline", O_RDONLY) = 3

63962 open("/proc/3/cmdline", O_RDONLY) = 3

63962 open("/proc/5/cmdline", O_RDONLY) = 3

....

--//先檢查命令是否包含"ora_"

...

63962 open("/etc/nsswitch.conf", O_RDONLY) = 3

63962 open("/etc/ld.so.cache", O_RDONLY) = 3

63962 open("/lib64/libnss_files.so.2", O_RDONLY) = 3

63962 open("/etc/passwd", O_RDONLY)     = 3

63962 open("/proc/63788/smaps", O_RDONLY) = 3

63962 open("/proc/63790/stat", O_RDONLY) = 3

63962 open("/proc/63790/cmdline", O_RDONLY) = 3

63962 open("/proc/63790/smaps", O_RDONLY) = 3

63962 open("/proc/63792/stat", O_RDONLY) = 3

63962 open("/proc/63792/cmdline", O_RDONLY) = 3

63962 open("/proc/63792/smaps", O_RDONLY) = 3

63962 open("/proc/63796/stat", O_RDONLY) = 3

63962 open("/proc/63796/cmdline", O_RDONLY) = 3

..


--//檢查使用者是否oracle,然後檢視smaps獲得記憶體使用...等等.


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

相關文章