ITPub博客

首页 > 应用开发 > IT综合 > RHEL中基于OS来统计某进程使用的IO;

RHEL中基于OS来统计某进程使用的IO;

原创 IT综合 作者:Steven1981 时间:2011-11-23 22:58:41 0 删除 编辑
今天在安装和使用STAP时碰到一个问题。 # stap disktop.stp semantic error: libdwfl failure (missing x86_64 kernel/module debuginfo under '/lib/modules/2.6.18-164.11.1.el5/build'): No such file or directory while resolving probe point kernel.function("vfs_read").return[@more@]

semantic error: no match while resolving probe point vfs.read.return semantic error: no match while resolving probe point kernel.function("vfs_write").return semantic error: no match while resolving probe point vfs.write.return Pass 2: analysis failed. Try again with another '--vp 01' option 出现这个错误是因为没有安装kernel_debuginfo包; 找到KERNEL相关的包: kernel-debuginfo-`uname -r`.x86_64.rpm kernel-debuginfo-common-`uname -r`.x86_64.rpm

附上 stap文件

=====================

######disk io
#!/usr/bin/env stap
#
# Copyright (C) 2007 Oracle Corp.
#
# Get the status of reading/writing disk every 5 seconds,
# output top ten entries
#
# This is free software,GNU General Public License (GPL);
# either version 2, or (at your option) any later version.
#
# Usage:
# ./disktop.stp
#
global io_stat,device,io_stat1,device1
global read_bytes,write_bytes,read_bytes1,write_bytes1

probe vfs.read.return {
if ($return>0) {
if (devname!="N/A") {/*skip read from cache*/
io_stat[pid(),execname(),uid(),ppid(),"R"] += $return
device[pid(),execname(),uid(),ppid(),"R"] = devname
read_bytes += $return
if (devname == "N/A"){
io_stat1[pid(),execname(),uid(),ppid(),"R"] += $return
device1[pid(),execname(),uid(),ppid(),"R"] = devname
read_bytes1 += $return
}
}
}
}
probe vfs.write.return {
if ($return>0) {
if (devname!="N/A") { /*skip update cache*/
io_stat[pid(),execname(),uid(),ppid(),"W"] += $return
device[pid(),execname(),uid(),ppid(),"W"] = devname
write_bytes += $return
}
if (devname=="N/A") {
io_stat1[pid(),execname(),uid(),ppid(),"w"] += $return
device1[pid(),execname(),uid(),ppid(),"w"] = devname
write_bytes1 += $return
}
}
}

probe timer.ms(5000) {
/* skip non-read/write disk */
if (read_bytes+write_bytes) {
printf("n%-25s, %-8s%4dKb/sec, %-7s%6dKb, %-7s%6dKbnn",ctime(gettimeofday_s()),"Raw Average:", ((read_bytes+write_bytes)/1024)/5,"Raw Read:",read_bytes/1024,"Raw Write:",write_bytes/1024)
printf("%8s %8s %8s %25s %8s %4s %12sn","UID","PID","PPID","CMD","DEVICE","T","BYTES")
foreach ([process,cmd,userid,parent,action] in io_stat- limit 10)
printf("%8d %8d %8d %25s %8s %4s %12dn",userid,process,parent,cmd,device[process,cmd,userid,parent,action],action,io_stat[process,cmd,userid,parent,action])
delete io_stat
delete device
read_bytes = 0
write_bytes = 0
}
if (read_bytes1+write_bytes1){
printf("n%-25s, %-8s%4dKb/sec, %-7s%6dKb, %-7s%6dKbnn",ctime(gettimeofday_s()),"Cach Average:", ((read_bytes+write_bytes)/1024)/5,"Cach Read:",read_bytes1/1024,"Cach Write:",write_bytes1/1024)
printf("%8s %8s %8s %25s %8s %4s %12sn","UID","PID","PPID","CMD","DEVICE","T","BYTES")
foreach ([process,cmd,userid,parent,action] in io_stat1- limit 10)
printf("%8d %8d %8d %25s %8s %4s %12dn",userid,process,parent,cmd,device1[process,cmd,userid,parent,action],action,io_stat1[process,cmd,userid,parent,action])
delete io_stat1
delete device1
read_bytes1 = 0
write_bytes1 = 0
}
printf("n-------------------------------------------------------------------------------------------------n")
}
probe end{
delete io_stat
delete device
delete read_bytes
delete write_bytes
delete io_stat1
delete device1
delete read_bytes1
delete write_bytes1

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/703656/viewspace-1056508/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论
  • 博文量
    127
  • 访问量
    837880