-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzilstat
executable file
·278 lines (252 loc) · 8.05 KB
/
zilstat
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/bin/sh
OPT_MEGA=0
OPT_POOL=0
OPT_TIME=0
OPT_TXG=0
FILTER=0
POOL=
LINES=-1
INTERVAL=1
COUNT=-1
SCRIPT_PATH=/tmp/dtrace.zilstat
trap 'rm -f $SCRIPT_PATH' 0
while getopts hl:Mp:t OPT
do
case $OPT in
l) LINES=$OPTARG
;;
M) OPT_MEGA=1
;;
p) OPT_POOL=1
POOL=$OPTARG
;;
t) OPT_TIME=1
;;
h|?)
ME="$(basename $0)"
cat 2>&1 <<' END' | sed -e 's/ //'
Usage: $ME [gMt][-l linecount] [-p poolname] [INTERVAL [COUNT]]
-M # print numbers as megabytes (base 10)
-t # print timestamp
-p poolname # only look at poolname
-l linecount # print header every linecount lines (default=only once)
interval in seconds or "txg" for transaction group commit intervals
note: "txg" only appropriate when -p poolname is used
count will limit the number of intervals reported
examples:
$ME # default output, 1 second samples
$ME 10 # 10 second samples
$ME 10 6 # print 6 x 10 second samples
$ME -p rpool # show ZIL stats for rpool only
output:
[TIME]
N-Bytes - data bytes written to ZIL over the interval
N-Bytes/s - data bytes/s written to ZIL over ther interval
N-Max-Rate - maximum data rate during any 1-second sample
B-Bytes - buffer bytes written to ZIL over the interval
B-Bytes/s - buffer bytes/s written to ZIL over ther interval
B-Max-Rate - maximum buffer rate during any 1-second sample
ops - number of synchronous iops per interval
<=4kB - number of synchronous iops <= 4kBytes per interval
4-32kB - number of synchronous iops 4-32kBytes per interval
>=32kB - number of synchronous iops >= 32kBytes per interval
note: data bytes are actual data, total bytes counts buffer size
END
exit 1
;;
esac
done
shift $((OPTIND - 1))
### option logic
if [ "$1" != "" ] && ( [ "$1" = "txg" ] || [ "$1" -gt 0 ] ); then
INTERVAL="$1";
shift
fi
if [ "$1" != "" ] && ( [ "$1" = "txg" ] || [ "$1" -gt 0 ] ) ; then
COUNT="$1";
shift
fi
if [ "$OPT_POOL" -eq 1 ]; then
FILTER=1
fi
case "$INTERVAL" in
"txg")
if [ "$OPT_POOL" -ne 1 ]; then
echo "error: -p poolname option must be used for txg intervals"
exit 1
fi
OPT_TXG=1
INTERVAL=0
;;
[0-9]*)
;;
*)
echo "error: interval must be a number or \"txg\""
exit 1
;;
esac
cat > $SCRIPT_PATH << EOF
#pragma D option quiet
inline int OPT_TIME = $OPT_TIME;
inline int OPT_TXG = $OPT_TXG;
inline int OPT_POOL = $OPT_POOL;
inline int OPT_MEGA = $OPT_MEGA;
inline int INTERVAL = $INTERVAL;
inline int LINES = $LINES;
inline int COUNTER = $COUNT;
inline int FILTER = $FILTER;
inline string POOL = "$POOL";
dtrace:::BEGIN
{
/* starting values */
mega = 1000000;
counts = COUNTER;
secs = INTERVAL;
interval = INTERVAL;
interval == 0 ? interval++ : 1;
line = 0;
last_event[""] = 0;
nused=0;
nused_max_per_sec=0;
nused_per_sec=0;
size=0;
size_max_per_sec=0;
size_per_sec=0;
syncops=0;
size_4k=0;
size_4k_32k=0;
size_32k=0;
OPT_TXG ? printf("waiting for txg commit...\n") : 1;
}
/*
* collect info when zil_lwb_write_start fires
*/
fbt::zil_lwb_write_start:entry
/OPT_POOL == 0 || POOL == args[0]->zl_dmu_pool->dp_spa->spa_name/
{
nused += args[1]->lwb_nused;
nused_per_sec += args[1]->lwb_nused;
size += args[1]->lwb_sz;
size_per_sec += args[1]->lwb_sz;
syncops++;
args[1]->lwb_sz <= 4096 ? size_4k++ : 1;
args[1]->lwb_sz > 4096 && args[1]->lwb_sz < 32768 ? size_4k_32k++ : 1;
args[1]->lwb_sz >= 32768 ? size_32k++ : 1;
}
/*
* Timer
*/
profile:::tick-1sec
{
OPT_TXG ? secs++ : secs--;
nused_per_sec > nused_max_per_sec ? nused_max_per_sec = nused_per_sec : 1;
nused_per_sec = 0;
size_per_sec > size_max_per_sec ? size_max_per_sec = size_per_sec : 1;
size_per_sec = 0;
}
/*
* Print header
*/
profile:::tick-1sec
/OPT_TXG == 0 && line == 0/
{
/* print optional headers */
OPT_TIME ? printf("%-20s ", "TIME") : 1;
/* print header */
OPT_MEGA ? printf("%10s %10s %10s %10s %10s %10s",
"N-MB", "N-MB/s", "N-Max-Rate",
"B-MB", "B-MB/s", "B-Max-Rate") :
printf("%10s %10s %10s %10s %10s %10s",
"N-Bytes", "N-Bytes/s", "N-Max-Rate",
"B-Bytes", "B-Bytes/s", "B-Max-Rate");
printf(" %6s %6s %6s %6s\n",
"ops", "<=4kB", "4-32kB", ">=32kB");
line = LINES;
}
fbt::txg_quiesce:entry
/OPT_TXG == 1 && POOL == args[0]->dp_spa->spa_name && line == 0/
{
OPT_TIME ? printf("%-20s ", "TIME") : 1;
OPT_MEGA ? printf("%10s %10s %10s %10s %10s %10s %10s",
"txg", "N-MB", "N-MB/s", "N-Max-Rate",
"B-MB", "B-MB/s", "B-Max-Rate") :
printf("%10s %10s %10s %10s %10s %10s %10s",
"txg", "N-Bytes", "N-Bytes/s", "N-Max-Rate",
"B-Bytes", "B-Bytes/s", "B-Max-Rate");
printf(" %6s %6s %6s %6s\n",
"ops", "<=4kB", "4-32kB", ">=32kB");
line = LINES;
}
/*
* Print Output
*/
profile:::tick-1sec
/OPT_TXG == 0 && secs == 0/
{
OPT_TIME ? printf("%-20Y ", walltimestamp) : 1;
OPT_MEGA ?
printf("%10d %10d %10d %10d %10d %10d",
nused/mega, nused/(mega*mega), nused_max_per_sec/mega,
size/mega, size/(interval*mega), size_max_per_sec/mega) :
printf("%10d %10d %10d %10d %10d %10d",
nused, nused/interval, nused_max_per_sec,
size, size/interval, size_max_per_sec);
printf(" %6d %6d %6d %6d\n",
syncops, size_4k, size_4k_32k, size_32k);
nused = 0;
nused_per_sec = 0;
nused_max_per_sec = 0;
size=0;
size_max_per_sec=0;
size_per_sec=0;
syncops=0;
size_4k=0;
size_4k_32k=0;
size_32k=0;
secs = interval;
counts--;
line--;
}
fbt::txg_quiesce:entry
/OPT_TXG == 1 && POOL == args[0]->dp_spa->spa_name/
{
secs <= 0 ? secs=1 : 1;
OPT_TIME ? printf("%-20Y ", walltimestamp) : 1;
OPT_MEGA ?
printf("%10d %10d %10d %10d %10d %10d %10d", args[1],
nused/mega, nused/(secs*mega), nused_max_per_sec/mega,
size/mega, size/(secs*mega), size_max_per_sec/mega) :
printf("%10d %10d %10d %10d %10d %10d %10d", args[1],
nused, nused/secs, nused_max_per_sec,
size, size/secs, size_max_per_sec);
printf(" %6d %6d %6d %6d\n",
syncops, size_4k, size_4k_32k, size_32k);
nused = 0;
nused_per_sec = 0;
nused_max_per_sec = 0;
size=0;
size_max_per_sec=0;
size_per_sec=0;
syncops=0;
size_4k=0;
size_4k_32k=0;
size_32k=0;
secs = 0;
counts--;
line--;
}
/*
* End of program
*/
profile:::tick-1sec
/OPT_TXG == 0 && counts == 0/
{
exit(0);
}
fbt::txg_quiesce:entry
/OPT_TXG == 1 && counts == 0/
{
exit(0);
}
EOF
/usr/sbin/dtrace -s $SCRIPT_PATH