1 Star2 Stars3 Stars4 Stars5 Stars (还没有评分)
Loading...

DTraceToolkit脚本解析(9)-syscallbyproc.d

syscallbyproc.d位于DTraceToolkitProc文件夹下,其功能是统计进程使用系统调用的次数。脚本代码就一行(略去版权信息):

syscall:::entry { @num[execname] = count(); }

脚本代码分析如下:
监听syscall Provider的 entry probeexecname内置变量记录了进程名,作为num这个aggregationkey。当probe触发后,把num里相应进程的统计次数加1

执行脚本,输出如下:

Nans-MacBook-Pro:Proc root# ./syscallbyproc.d 
dtrace: script './syscallbyproc.d' matched 490 probes
^C

  loginwindow                                     1
  CVMServer                                       2
  coreaudiod                                      2
  CalendarAgent                                   3
  SocialPushAgent                                 4

......

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.