This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Updated script to work with current systemtap


Dave Jone's mentioned Daniel Berrange's script at his OLS talk, "Why Userspace Sucks--Or 101 Really Dumb Things Your App Shouldn't Do". I took a look at the scrit to see whether it runs. There have been some changes in the SystemTap language since the creation of script that prevented the initprocs.stp script from running. I made some trivial modifications. The attached script run on my machine this weekend with the current snapshot of systemtap.

-Will
#
# Daniel Berrange's initprocs.stp script updated to work with
# systemtap as of 20060722
#

global indent

function get_usertime:long() %{
  THIS->__retvalue = current->utime + current->signal->utime;
%}

function get_systime:long() %{
  THIS->__retvalue = current->stime + current->signal->stime;
%}

function timestamp:string() {
  return sprintf("%d %s", gettimeofday_ms(), indent[pid()])
}

function proc:string() {
  return sprintf("%d (%s)", pid(), execname())
}

function push(pid, ppid) {
  indent[pid] = indent[ppid] . "  "
}

function pop(pid) {
  delete indent[pid]
}

probe kernel.function("sys_clone").return {
  print(timestamp() . proc() . " forks " . sprint(retval()) . "\n")
  push(retval(), pid())
}

probe kernel.function("do_execve") {
  print(timestamp() . proc() . " execs " . kernel_string($filename) . "\n")
}

probe kernel.function("sys_open") {
  if ($flags & 1) {
    print(timestamp() . proc() . " writes " . user_string($filename) . "\n")
  } else {
    print(timestamp() . proc() . " reads " . user_string($filename) . "\n")
  }
} 

probe kernel.function("do_exit") {
  print(timestamp() . proc() . " exit with user " . sprint(get_usertime()) .
	" sys " . sprint(get_systime()) . "\n")
  pop(pid())
}

probe timer.jiffies(100) {
  if (pid() != 0) {
    print(timestamp() . proc() . " tick with user " . sprint(get_usertime()) .
	" sys " . sprint(get_systime()) . "\n")
  }
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]