-
Notifications
You must be signed in to change notification settings - Fork 0
/
iodump.stp
executable file
·61 lines (51 loc) · 1.53 KB
/
iodump.stp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/stap -g
global outbuf
function buflog (msg:string) {
printf("%s", msg)
outbuf = outbuf . msg
}
/* data collection: SCSI disk */
%(kernel_v<"2.6.24" %?
probe module("sd_mod").function("sd_init_command") !, kernel.function("sd_init_command") {
device=kernel_string($SCpnt->request->rq_disk->disk_name)
sector_size=$SCpnt->device->sector_size
nr_sectors=$SCpnt->request->nr_sectors
devices[device] = 1
%(kernel_v>="2.6.19" %?
if ($SCpnt->request->cmd_flags & 1)
%:
if ($SCpnt->request->flags & 1)
%)
read_or_write = "w"
else
read_or_write = "r"
printf("%d,hostname,scsi_id,%s,%s,%d,%d,%d\n", gettimeofday_s(), device, read_or_write, $rq->sector, sector_size, $rq->nr_sectors)
}
%:
%{
#include <scsi/scsi_device.h>
%}
function get_sector_size:long (data:long) %{ /* pure */
struct scsi_device *sdp = (struct scsi_device *)((long)THIS->data);
THIS->__retvalue = kread(&(sdp->sector_size));
CATCH_DEREF_FAULT();
%}
probe module("sd_mod").function("sd_prep_fn") !, kernel.function("sd_prep_fn") {
device=kernel_string($rq->rq_disk->disk_name)
sector_size=get_sector_size($q->queuedata)
nr_sectors=$rq->nr_sectors
devices[device] = 1
if ($rq->cmd_flags & 1)
read_or_write = "w"
else
read_or_write = "r"
printf("%d,hostname,scsi_id,%s,%s,%d,%d,%d\n", gettimeofday_s(), device, read_or_write, $rq->sector, sector_size, $rq->nr_sectors)
print_backtrace()
}
%)
probe begin {
outbuf = "# timestamp,hostname,scsi_id,disk,operation,block,sectors,sector_size\n"
}
probe end {
printf("%s", msg)
}