This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
implementation of OLS 2005 example in current language
- From: William Cohen <wcohen at redhat dot com>
- To: SystemTAP <systemtap at sources dot redhat dot com>
- Date: Tue, 06 Sep 2005 19:10:04 -0400
- Subject: implementation of OLS 2005 example in current language
I implemented the OLS 2005 example that tracked opens, reads, and writes
in the current systemtap language. I did the averages by hand. This
compiled and ran with a current snapshot of systemtap.
$ stap fileops.stp
4 opens by process "udevd"
75 opens by process "init"
31 opens by process "hald"
16 opens by process "automount"
reads by process "stap": 2 Total bytes= 16384. Average:8192.
reads by process "init": 155 Total bytes= 140360. Average:905.
reads by process "sshd": 492 Total bytes= 8060928. Average:16384.
reads by process "bash": 703 Total bytes= 24576. Average:34.
writes by process "init": 141 Total bytes= 11972. Average:84.
writes by process "sshd": 535 Total bytes= 87505. Average:163.
writes by process "bash": 283 Total bytes= 60052. Average:212.
writes by process "stap": 1 Total bytes= 4. Average:4.
-Will
# fileops.stp
# A reimplementation of systemtap example given at OLS 2005
# in the current systemtap language.
#
# 9/6/2005
# Will Cohen
global opens
global reads
global reads_bytes
global writes
global writes_bytes
probe kernel.function("sys_open") {
opens[pexecname()] += 1;
}
probe kernel.function("sys_read") {
++reads[pexecname()];
reads_bytes[pexecname()] += $count;
}
probe kernel.function("sys_write") {
++writes[pexecname()];
writes_bytes[pexecname()] += $count;
}
probe end {
foreach (pexecname in opens)
log( string(opens[pexecname]) . " opens by process \""
. pexecname ."\"");
foreach (pexecname in reads)
log("reads by process \"" . pexecname . "\": "
. string(reads[pexecname])
. " Total bytes= "
. string(reads_bytes[pexecname]) . ". Average:"
. string(reads_bytes[pexecname]/reads[pexecname])
. ".");
foreach (pexecname in writes)
log("writes by process \"" . pexecname . "\": "
. string(writes[pexecname])
. " Total bytes= "
. string(writes_bytes[pexecname]) . ". Average:"
. string(writes_bytes[pexecname]/writes[pexecname])
. ".");
}