kstat,获取区域中运行的轻量级进程数

时间:2016-06-17 02:44:13

标签: solaris opensolaris smartos kstat

SmartOS区域在区域包中定义了上限或最大数量的轻量级进程。要检查我当前的设置是否有意义,我想收集一段时间内(从区域内)轻量级进程的总数。我已经有工具来收集kstat计数器,所以我更愿意使用它。我注意到prstat提供了lwps计数以及有关prstat获取此值的任何信息可能会有所帮助。

与此同时,我已经能够使用'caps:*:nprocs_zone_*:usage''unix:0:system_misc:nproc'获取进程数,但没有任何关于轻量级进程的进程。

总结一下,我想知道:

  • 如果有任何kstat计数器表示lwps或每个进程计数器的总数,我可以总结得到这个值。
  • 如果没有,prstat如何获得总lwps数?
  • 有没有其他方法可以获得此值? (希望不解析prstat输出)

1 个答案:

答案 0 :(得分:0)

prstat正在查询/ proc文件系统以获取信息,针对prstat命令运行truss的示例显示:

open("/proc/25841/psinfo", O_RDONLY)            = 158

proc记录良好here,或者搜索“oracle man pages section 4 File Formats proc”。

在每个/ proc / [pid]目录中都存在一个/ proc / [pid] / lwp /目录。例如:

root@sol11:/proc/597/lwp# ls -l
total 35
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 1
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 10
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 11
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 12
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 13
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 14
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 15
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 16
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 17
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 18
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 19
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 2
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 20
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 21
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 22
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 23
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 24
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 26
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 27
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 28
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 29
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 3
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 30
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 31
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 33
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 34
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 35
dr-xr-xr-x   2 root     root         256 Jun  3 13:07 36
dr-xr-xr-x   2 root     root         256 Jun 16 11:16 37
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 4
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 5
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 6
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 7
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 8
dr-xr-xr-x   2 root     root         256 Jun  3 13:06 9

针对同一进程运行ps将读取每个lwp的内容并将其呈现回来,这个特定的pid与fmd服务有关。

root@sol11:/proc/597/lwp# ps -Lp 597
  PID   LWP LNAME            TTY        LTIME CMD
  597     1 -                ?           0:00 fmd
  597     2 fmd_timerq_exec  ?           0:04 fmd
  597     3 fmd-self-diagnosis ?           0:00 fmd
  597     4 sysevent-transport ?           0:00 fmd
  597     5 door_xcreate_startf ?           0:00 fmd
  597     6 door_xcreate_startf ?           0:00 fmd
  597     7 subscriber_event_handler ?           0:01 fmd
  597     8 fmd_door_server  ?           0:00 fmd
  597     9 fmd_thread_start ?           0:00 fmd
  597    10 cpumem-retire    ?           0:00 fmd
  597    11 ses-log-transport ?           0:04 fmd
  597    12 ext-event-transport ?           0:00 fmd
  597    13 door_xcreate_startf ?           0:00 fmd
  597    14 door_xcreate_startf ?           0:00 fmd
  597    15 sas-cabling      ?           0:01 fmd
  597    16 io-retire        ?           0:00 fmd
  597    17 eft              ?           0:00 fmd
  597    18 endurance-transport ?           0:00 fmd
  597    19 fdd-msg          ?           0:00 fmd
  597    20 disk-transport   ?           0:00 fmd
  597    21 sensor-transport ?           0:04 fmd
  597    22 -                ?           0:00 <defunct>
  597    23 syslog-msgs      ?           0:00 fmd
  597    24 disk-diagnosis   ?           0:00 fmd
  597    26 zfs-retire       ?           0:00 fmd
  597    27 fru-monitor      ?           0:02 fmd
  597    28 -                ?           0:00 fmd
  597    29 software-response ?           0:00 fmd
  597    30 enum-transport   ?           0:00 fmd
  597    31 non-serviceable  ?           0:00 fmd
  597    33 fabric-xlate     ?           0:00 fmd
  597    34 software-diagnosis ?           0:00 fmd
  597    35 zfs-diagnosis    ?           0:00 fmd
  597    36 umem_update_thread ?           0:06 fmd
  597    37 fmd_door_server  ?           0:00 fmd

以下命令应该为您解析总LWP。

prstat -n 1,1 1 1 | nawk '/Total/ { print $4 }'

使用zlogin -c运行以获取区域中LWP的详细信息。您可能可以使用dtrace获取相同的信息,但我不知道如何执行此操作。如果您发现,请回复您的发现...

如果您想深入研究LWP信息,-lL开关可提供有关LWP的详细信息,例如:

root@sol11:/etc# ps -lLp 597
 F S    UID   PID  PPID   LWP LNAME              C PRI NI     ADDR     SZ    WCHAN TTY        LTIME CMD
 0 S      0   597     1     1 -                  0  40 20        ?  25470        ? ?           0:00 fmd
 0 S      0   597     1     2 fmd_timerq_exec    0  40 20        ?  25470        ? ?           0:04 fmd
 0 S      0   597     1     3 fmd-self-diagnosis   0  40 20        ?  25470        ? ?           0:00 fmd
 0 S      0   597     1     4 sysevent-transport   0  40 20        ?  25470        ? ?           0:00 fmd
 0 S      0   597     1     5 door_xcreate_startf   0  40 20        ?  25470        ? ?           0:00 fmd
 0 S      0   597     1     6 door_xcreate_startf   0  40 20        ?  25470        ? ?           0:00 fmd
 0 S      0   597     1     7 subscriber_event_handler   0  40 20        ?  25470        ? ?           0:01 fmd

HTH。