Friday, December 09, 2005

Measuring NFS traffic with DTrace

Below you can find simple script written in DTrace which will show you in a given time intervals what is a distribution of data written and read to/from NFS mounted filesystems in Mb per second (average in the interval). It will be updated continuously every given amount of time.

Script expects four arguments: low high step interval. First two of them are low and high of a range in Mbs you want your output, step describes resolution of the output and interval is a resolution of a measurement (time interval from which Mbs is calculated). In an example below I wanted to see output in a range 50-150Mbs with 5Mbs step calculated for intervals of 10s and see results every 10s. As you can see most of the time I have on average 90-120Mbs generated to/from NFS servers.
Note that this is only an estimate.


bash-3.00# cat io-nfs-throughput.d
#!/usr/sbin/dtrace -qs

BEGIN
{
bsum = 0;
}

io:nfs::start
{
bsum += args[0]->b_bcount;
}

tick-$4
{
@a["Mbs"] = lquantize(bsum*8/($4*1024*1024),$1,$2,$3);
printa(@a);
bsum=0;
}

bash-3.00# ./io-nfs-throughput.d 50 150 5 10s
[...] after some time
Mbs
value ------------- Distribution ------------- count
55 | 0
60 | 1
65 | 2
70 | 2
75 |@ 3
80 |@ 8
85 |@@@ 17
90 |@@@@@ 32
95 |@@@ 16
100 |@@@@ 23
105 |@@@@ 22
110 |@@@@ 21
115 |@@@@ 21
120 |@@@ 19
125 |@@@ 17
130 |@@ 14
135 |@@ 11
140 |@ 7
145 | 0
>= 150 |@ 4

1 comment:

Anonymous said...

Good insights. You might be interested in a new tool available at www.ortera.com. Your perspective would be valuable.