forked from hybridlogic/D
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilesystem-events.d
executable file
·58 lines (50 loc) · 1.37 KB
/
filesystem-events.d
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
#!/usr/sbin/dtrace -s
/* See vfssnoop.d in the d-trace book if you want filenames */
#pragma D option quiet
#pragma D option defaultargs
#pragma D option switchrate=10hz
#pragma D option dynvarsize=256m
#pragma D option cleanrate=5000hz
vfs::vop_read:entry
/$$1 == "read"/
{
self->b = args[1]->a_uio->uio_resid;
self->iotype = "read";
}
vfs::vop_open:entry, vfs::vop_close:entry, vfs::vop_ioctl:entry,
vfs::vop_getattr:entry, vfs::vop_readdir:entry
/$$1 == "read"/
{
self->b = 0;
self->iotype = "read";
}
vfs::vop_write:entry
/$$1 == "write"/
{
self->b = args[1]->a_uio->uio_resid;
self->iotype = "write";
}
vfs::vop_read:return, vfs::vop_write:return,
vfs::vop_open:return, vfs::vop_close:return, vfs::vop_ioctl:return,
vfs::vop_getattr:return, vfs::vop_readdir:return
{
self->vp = args[0];
self->mount = self->vp != NULL ? self->vp->v_mount : 0;
self->fi_mount = self->mount ? stringof(self->mount->mnt_stat.f_mntonname) : "<unknown>"; /* where we mount on */
}
vfs::vop_read:return, vfs::vop_open:return, vfs::vop_close:return,
vfs::vop_ioctl:return, vfs::vop_getattr:return, vfs::vop_readdir:return
/$$1 == "read"/
{
@mountio[self->fi_mount] = sum(self->b);
}
vfs::vop_write:return
/$$1 == "write"/
{
@mountio[self->fi_mount] = sum(self->b);
}
profile:::tick-1sec {
printa("%s %@d\n", @mountio);
printf("===\n");
trunc(@mountio);
}