系统调用探测示例
前面已经简要解释了脚本语法和探测类型,现在来看一个使用系统调用探测的简单ProbeVue脚本。
清单1:系统调用ProbeVue脚本示例
/* Function prototype for read in order to access input args */
int read( int fd, char *buf, unsigned long size );
String sFormat0[10];
String sFormat1[10];
String sLen[2];
@@BEGIN
{
/* Initialize printf format strings */
sLen = "9";
sFormat0 = "%" + sLen + "d,";
sFormat1 = "%" + sLen + "d," + "%" + sLen + "dn";
sFormat2 = "%" + sLen + "s,%" + sLen + "s,%" + sLen + "sn";
/* Print header */
printf( sFormat2, "Requested", "Actual", "Average" );
/* Create list to maintain rolling average */
rollingAvg = list();
}
/* Probe to print the size of the read buffer. */
@@syscall:*:read:entry
/* Only for the currently executing program. */
when ( $__CPID == __pid ) {
/* __arg3 represents the size of the read buffer. */
printf( sFormat0, __arg3 );
}
/* Probe to print the actual number of bytes read i.e. the return value from read. */
@@syscall:*:read:exit
/* Only for the currently executing program. */
when ( $__CPID == __pid ) {
/* Append return value (__rv) to list */
append( rollingAvg, __rv );
printf( sFormat1, __rv, avg( rollingAvg) );
}
@@END
{
} (编辑:源码网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|