forked from kdavyd/dtrace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzfsio.d
46 lines (42 loc) · 2.34 KB
/
zfsio.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
#!/usr/sbin/dtrace -s
#pragma D option quiet
/* Description: This script will show read/write IOPs and throughput for ZFS
* filesystems and zvols on a per-dataset basis. It can be used to estimate
* which dataset is causing the most I/O load on the current system. It should
* only be used for comparative analysis. */
/* Author: [email protected] */
/* Copyright 2012, Nexenta Systems, Inc. All rights reserved. */
/* Version: 0.4b */
dmu_buf_hold_array_by_dnode:entry
/args[0]->dn_objset->os_dsl_dataset && args[3]/ /* Reads */
{
this->ds = stringof(args[0]->dn_objset->os_dsl_dataset->ds_dir->dd_myname);
this->parent = stringof(args[0]->dn_objset->os_dsl_dataset->ds_dir->dd_parent->dd_myname);
this->path = strjoin(strjoin(this->parent,"/"),this->ds); /* Dirty hack - parent/this format doesn't guarantee full path */
@ior[this->path] = count();
@tpr[this->path] = sum(args[2]);
@bsr[this->path] = avg(args[2]);
@distr[strjoin(this->path, " Reads")] = quantize(args[2]);
}
dmu_buf_hold_array_by_dnode:entry
/args[0]->dn_objset->os_dsl_dataset && !args[3]/ /* Writes */
{
this->ds = stringof(args[0]->dn_objset->os_dsl_dataset->ds_dir->dd_myname);
this->parent = stringof(args[0]->dn_objset->os_dsl_dataset->ds_dir->dd_parent->dd_myname);
this->path = strjoin(strjoin(this->parent,"/"),this->ds);
@iow[this->path] = count();
@tpw[this->path] = sum(args[2]);
@bsw[this->path] = avg(args[2]);
@distw[strjoin(this->path, " Writes")] = quantize(args[2]);
}
tick-1sec,END
{
printf("%Y operations bandwidth blocksize\n",walltimestamp);
printf("Dataset read write read write read write\n");
printf(" ------ ------ ---------- ---------- ------ ------\n");
printa("%-40s %@-6d %@-6d %@-10d %@-10d %@-6d %@-6d\n",@ior,@iow,@tpr,@tpw,@bsr,@bsw);
trunc(@ior); trunc(@tpr); trunc(@iow); trunc(@tpw); trunc(@bsr); trunc(@bsw);
/* clear(@ior); clear(@tpr); clear(@iow); clear(@tpw); clear(@bsr); clear(@bsw);*/
/* TODO: Make script more interactive. Above, uncomment clear() and comment trunc() line in order to change
truncate behavior, or comment out both lines to get cumulative stats. */
}