I have been using Eric Kustarz's "nfstop" dtrace script to keep an eye on
a server; the output looks like this:
host: 129.146.226.97 num nfs calls: 6
host: 129.145.154.106 num nfs calls: 7
host: 129.146.11.146 num nfs calls: 8
host: 129.146.108.85 num nfs calls: 8
host: 10.4.180.27 num nfs calls: 11
host: 129.146.228.172 num nfs calls: 16
host: 129.146.11.145 num nfs calls: 17
host: 129.146.228.151 num nfs calls: 19
host: 129.146.228.144 num nfs calls: 22
...
While this is helpful, I'd much rather format the output as follows:
HOST OPS
129.146.226.97 6
129.145.154.106 7
129.146.11.146 8
129.146.108.85 8
10.4.180.27 11
129.146.228.172 16
129.146.11.145 17
129.146.228.151 19
129.146.228.144 22
Which to my eyes is a lot easier to process rapidly.
The problem here is that the IP address is stored byte by byte in the
aggregation, as follows:
@hosts[self->sin_addr[0], self->sin_addr[1], self->sin_addr[2],
self->sin_addr[3]] = count();
(There is a similar clause for ipv6 addresses which I have omitted here).
And so the printa() looks like this:
printa("\nhost: %d.%d.%d.%d num nfs calls: [EMAIL PROTECTED]", @hosts)
This would seem to make it fairly difficult to align the columns of output,
unless I zero-fill each IP address (ugly). My initial thought was to trying
something like this:
s = sprintf("%d.%d.%d.%d", self->sin_addr[0], self->sin_addr[1],
self->sin_addr[2], self->sin_addr[3]])
@hosts[s] = count();
...
printa("%20s\t\t%d")
Unfortunately, there is no sprintf, I presume because printf processing happens
up in userland. So I was wondering if there's a best practice here, or some
other obvious way to cope with this problem?
-dp
--
Daniel Price - Solaris Kernel Engineering - [EMAIL PROTECTED] - blogs.sun.com/dp
_______________________________________________
dtrace-discuss mailing list
[email protected]