0

Is there a way to get DTrace printf output Bytes in human readable format GB, TB, ... ?

For example here:

#!/usr/sbin/dtrace -s

#pragma D option quiet

dtrace:::BEGIN
{
        trace("Tracing... Hit Ctrl-C to end.\n");
}

nfsv3:::op-read-done
{
        @readbytes[args[1]->noi_curpath] = sum(args[2]->res_u.ok.data.data_len);
}


nfsv3:::op-write-done
{
        @writebytes[args[1]->noi_curpath] = sum(args[2]->res_u.ok.count);
}

dtrace:::END
{
        printf("\n%12s %12s  %s\n", "Rbytes", "Wbytes", "Pathname");
        printa("%@12d %@12d  %s\n", @readbytes, @writebytes);
}

Source http://wikis.sun.com/display/DTrace/nfsv3+Provider

Aleksandr Levchuk
  • 2,415
  • 3
  • 21
  • 41

1 Answers1

1

I don't know dtrace, but looking at that wiki page shows that it has basic math operators built in. So there is no reason you couldn't multiply the numbers before printing them.

Nathan Powell
  • 579
  • 2
  • 6