dtrace translators
摘录诞生的原因。
A translator is a collection of D assignment statements provided by the supplier of an interface that can be used to translate an input expression into an object of struct type. Like any D statements, the body of the translator can refer directly to kernel types and kernel global data structures, as well as other DTrace variables.
刚学到的就是返回的fds translator了.
#!/usr/sbin/dtrace -s
#
syscall::read:entry
/arg0!=0/
{
trace(execname);
trace(fds[arg0].fi_pathname);
trace(fds[arg0].fi_fs);
}
可以快捷的得到哪个程序在读取哪个文件。
CPU ID FUNCTION:NAME
28 1512 read:entry sshd sockfs
28 1512 read:entry sshd /devices/pseudo/clone@0:ptm specfs
8 1512 read:entry cat /oracle/DB1/home/binzhang/t.d vxfs
8 1512 read:entry cat /oracle/DB1/home/binzhang/tcp.d vxfs