Hello everyone,

Is it possible to convert an int to a string in DTrace?

E.g., I'd like the following script to work (it's an example from dtrace_io(4), 
but with device unit number added):

#!/usr/sbin/dtrace -s

#pragma D option quiet

io:::start
{
        this->unit_number = args[1]->unit_number >= 0 ? 
(string)args[1]->unit_number : "";
        @[args[1]->device_name, this->unit_number, execname, pid] = 
sum(args[0]->bio_bcount);
}

END
{
        printf("%10s%-3s %20s %10s %15s\n", "DEVICE", "", "APP", "PID", 
"BYTES");
        printa("%10s%-3s %20s %10d %15@d\n", @);
}

(Of course, the `(string)` cast does not work here because it's just not how 
DTrace works.)

Best,
Mateusz

Reply via email to