加入收藏 | 设为首页 | 会员中心 | 我要投稿 应用网_丽江站长网 (http://www.0888zz.com/)- 科技、建站、数据工具、云上网络、机器学习!
当前位置: 首页 > 服务器 > 搭建环境 > Unix > 正文

ProbeVue简介

发布时间:2016-05-19 20:06:01 所属栏目:Unix 来源:网络整理
导读:即使对于老练的程序员和系统管理员,应用程序开发和故障排除也是艰难的任务。即使有了最好的调试器,程序员有时候仍然希望用简单的打印语句检查应用程序正在执

系统调用探测示例

前面已经简要解释了脚本语法和探测类型,现在来看一个使用系统调用探测的简单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
{
}

(编辑:应用网_丽江站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读