Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

        trace("Tracing... Hit Ctrl-C to end.\n");

        @readbytes[args[1]->noi_curpath] = sum(args[2]->;

        @writebytes[args[1]->noi_curpath] = sum(args[2]->res_u.ok.count);

        printf("\n%12s %12s  %s\n", "Rbytes", "Wbytes", "Pathname");
        printa("%@12d %@12d  %s\n", @readbytes, @writebytes);


share|improve this question

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.

share|improve this answer
I think you would want to divide in this situation, but the concept still stands :) – Mark Henderson Aug 26 '11 at 2:40
Heh, nice. Wasn't thinking at all. – Nathan Powell Aug 26 '11 at 23:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.