public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* iotaskbypid
@ 2005-10-06 20:27 Badari Pulavarty
  0 siblings, 0 replies; only message in thread
From: Badari Pulavarty @ 2005-10-06 20:27 UTC (permalink / raw)
  To: systemtap

[-- Attachment #1: Type: text/plain, Size: 1739 bytes --]

Hi,

Here is systemtap script to show number of open/read/write 
operations performed by pid.

Its based on iotask.stp except that its based on "pid"
instead of process name. With original iotask.stp, most
of my DB2 processes operations are accounted as a single
process.

Thanks,
Badari

[root@elm3b23 systemtap.samples]# stap iotaskbypid.stp
starting probe
process,pid: stpd,9751
reads n, sum, avg=3,24576,8192
writes n, sum, avg=2,19,9

process,pid: 05-wait_for_sys,9756
opens n=6
reads n, sum, avg=7,8480,1211

process,pid: sshd,5588
reads n, sum, avg=2,32768,16384
writes n, sum, avg=2,65,32

process,pid: dd,9692
reads n, sum, avg=2947,386269184,131072
writes n, sum, avg=2947,386269184,131072

process,pid: 10-udev.hotplug,9757
opens n=5
reads n, sum, avg=6,7456,1242

process,pid: dd,9693
reads n, sum, avg=2134,559415296,262144
writes n, sum, avg=2134,559415296,262144

process,pid: dd,9694
reads n, sum, avg=1198,628097024,524288
writes n, sum, avg=1198,628097024,524288

process,pid: 20-hal.hotplug,9759
opens n=3
reads n, sum, avg=3,1696,565

process,pid: hald,3147
opens n=22
reads n, sum, avg=9,9216,1024

process,pid: default.hotplug,9760
opens n=15
reads n, sum, avg=19,31791,1673

process,pid: udev,9758
opens n=7
reads n, sum, avg=7,8480,1211

process,pid: udevd,1309
reads n, sum, avg=2,8,4
writes n, sum, avg=1,4,4

process,pid: uname,9762
opens n=2
reads n, sum, avg=2,672,336
writes n, sum, avg=1,11,11

process,pid: env,9763
opens n=2
reads n, sum, avg=2,672,336
writes n, sum, avg=1,152,152

process,pid: hotplug,9753
reads n, sum, avg=1,1160,1160

process,pid: sendmail,3024
opens n=2
reads n, sum, avg=2,2048,1024

process,pid: irqbalance,2759
opens n=11
reads n, sum, avg=2,2048,1024
writes n, sum, avg=10,10,1


[-- Attachment #2: iotaskbypid.stp --]
[-- Type: text/plain, Size: 1166 bytes --]

# iotaskbypid.stp
# Same as iotask.stp, except its based on pid instead of process name

global names, opens
global reads, read_bytes
global writes, write_bytes
global pidnames

probe kernel.function("sys_open") {
   ++names[pid()]; ++opens[pid()];
   pidnames[pid()] = execname()
}

probe kernel.function("sys_read") {
  ++names[pid()]; ++reads[pid()];
  read_bytes[pid()] += $count;
   pidnames[pid()] = execname()
}

probe kernel.function("sys_write") {
  ++names[pid()]; ++writes[pid()];
  write_bytes[pid()] += $count;
   pidnames[pid()] = execname()
}

probe begin { log( "starting probe" ); }

probe end {
  foreach(name in names){
    log ("process,pid: " . pidnames[name] . "," . string(name));
    if (opens[name]) 
      log( "opens n=" . string(opens[name]));
    if ( reads[name]){
      count = reads[name]; total=read_bytes[name];
      log("reads n, sum, avg=". string(count)
        . "," . string(total) . "," . string(total/count));
    }
    if (writes[name]){
      count = writes[name]; total=write_bytes[name];
      log("writes n, sum, avg=". string(count)
        . "," . string(total) . "," . string(total/count));
    }
    log("");
  }
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-06 20:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-06 20:27 iotaskbypid Badari Pulavarty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).