This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: Updated script to work with current systemtap
- From: William Cohen <wcohen at redhat dot com>
- To: William Cohen <wcohen at redhat dot com>
- Cc: SystemTAP <systemtap at sources dot redhat dot com>, "Daniel P. Berrange" <berrange at redhat dot com>
- Date: Mon, 24 Jul 2006 14:53:05 -0400
- Subject: Re: Updated script to work with current systemtap
- References: <44C4FC07.9080308@redhat.com>
William Cohen wrote:
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
A minor correction for the obtaining the return value in the script.
-Will
#
# Daniel Berrange's initprocs.stp script updated to work with
# systemtap as of 20060724
#
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")
}
}