简体   繁体   English

Dtrace没有为NodeJS收集任何数据

[英]Dtrace is not collecting any data for NodeJS

I'm trying to profile NodeJS with Dtrace and it is not working out. 我正在尝试使用Dtrace对NodeJS进行分析,但无法解决。 The command that I'm using is: 我正在使用的命令是:

dtrace -n 'profile-97/execname == "node" && arg1/{@[jstack(150, 8000)] = count(); } tick-60s { exit(0); }' > stacks.out

The output that I get is: 我得到的输出是:

CPU     ID                    FUNCTION:NAME
  0 312432                        :tick-30s

If I do dtrace -l then I get for example: 如果我执行dtrace -l那么我得到例如:

58814      instr            kernel              setup_APIC_eilvt-jne 0xffffffff81045e27
58815      instr            kernel               setup_APIC_eilvt-je 0xffffffff81045e34
58816      instr            kernel               setup_APIC_eilvt-je 0xffffffff81045e38
58817      instr            kernel            setup_APIC_eilvt-callr 0xffffffff81045e46
58818      instr            kernel            setup_APIC_eilvt-callr 0xffffffff81045e6a
58819      instr            kernel      lapic_timer_setup.part.4-cli 0xffffffff81045ea0
58820      instr            kernel      lapic_timer_setup.part.4-jbe 0xffffffff81045eaa
58821      instr            kernel      lapic_timer_setup.part.4-jbe 0xffffffff81045eaf
58822      instr            kernel    lapic_timer_setup.part.4-callr 0xffffffff81045ed4
58823      instr            kernel              lapic_timer_setup-je 0xffffffff81045f39
58824      instr            kernel            lapic_timer_setup-repz 0xffffffff81045f3b
58825      instr            kernel     local_apic_timer_interrupt-je 0xffffffff81045f74
58826      instr            kernel  local_apic_timer_interrupt-callr 0xffffffff81045f90
58827      instr            kernel     local_apic_timer_interrupt-je 0xffffffff81045f99
58828      instr            kernel              clear_local_APIC-jne 0xffffffff8104610e
58829      instr            kernel               clear_local_APIC-jg 0xffffffff810461c3
58830      instr            kernel               clear_local_APIC-je 0xffffffff8104629a
58831      instr            kernel            disable_local_APIC-jne 0xffffffff810463bd
58832      instr            kernel             disable_local_APIC-je 0xffffffff810463c7
58833      instr            kernel          disable_local_APIC-callr 0xffffffff810463c9
58834      instr            kernel           disable_local_APIC-repz 0xffffffff81046400
58835      instr            kernel                 lapic_suspend-jne 0xffffffff8104641d
58836      instr            kernel                  lapic_suspend-jg 0xffffffff81046555
58837      instr            kernel                 lapic_suspend-cli 0xffffffff81046561
58838      instr            kernel               lapic_suspend-callr 0xffffffff81046568

And if I list all the processes that open files with: 如果我列出了所有打开文件的过程,则:

dtrace -q -n syscall::open:entry'{ printf("%-16s%-16s\n", execname,copyinstr(arg0)); }'

I get all the processes opening files, it even show NodeJS starting and getting ready for work :) 我得到了所有打开文件的进程,它甚至显示NodeJS正在启动并准备工作:)

vminfo          /var/run/utmp
vminfo          /var/run/utmp
systemd         /proc/145/cgroup
vminfo          /var/run/utmp
vminfo          /var/run/utmp
vminfo          /var/run/utmp
vminfo          /var/run/utmp
systemd         /proc/460/cgroup
vminfo          /var/run/utmp
vminfo          /var/run/utmp
node            /etc/ld.so.cache
node            /lib/x86_64-linux-gnu/libdl.so.2
node            /lib/x86_64-linux-gnu/librt.so.1
node            /usr/lib/x86_64-linux-gnu/libstdc++.so.6
node            /lib/x86_64-linux-gnu/libm.so.6
node            /lib/x86_64-linux-gnu/libgcc_s.so.1
node            /lib/x86_64-linux-gnu/libpthread.so.0
node            /lib/x86_64-linux-gnu/libc.so.6
node            /dev/urandom
node            /home/davidgatti/test/ble.js
node            /etc/resolv.conf
node            /etc/nsswitch.conf
node            /dev/urandom
node            /dev/pts/0
node            /dev/null
node            /dev/pts/0
vminfo          /var/run/utmp
vminfo          /var/run/utmp
systemd         /proc/145/cgroup

Question

What I'm doing wrong? 我做错了什么? How should I probe NodeJS or any other process to get some useful info out? 我应该如何探查NodeJS或任何其他进程以获取一些有用的信息?

Sadly this won't work under Linux because Dtrace it strictly tied with the system kernel. 遗憾的是,这在Linux下不起作用,因为Dtrace严格与系统内核绑定。

Dtrace works for example under macOS or Solaris because there is one version of the kernel, and if any changes are made the authors can do the appropriate changed to Dtrace. Dtrace例如在macOS或Solaris下工作,因为存在一个内核版本,并且如果进行了任何更改,那么作者可以对Dtrace进行适当的更改。

Since not only Linux has many different kernels in each distribution, you are free to compile your own version however you want, and this means that it is impossible to create a working Dtrace for this system. 由于不仅Linux在每个发行版中都有许多不同的内核,所以您可以随意编译自己的版本,这意味着不可能为该系统创建有效的Dtrace。

Since Dtrace needs to hook in specific parts of the kernel to be able to trace what is going on within the app. 由于Dtrace需要挂接内核的特定部分才能跟踪应用程序中发生的事情。

You can read more about this in the Issue section of the original Dtrace for linux repo. 您可以在原始Dtrace for Linux存储库的“ 发行”部分中了解有关此内容的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM