2

I need to read disk queue length (separately for read and write operations) on Mac OSX. I already came to conclusion that this may be done only via dtrace (I would be happy to be wrong here, however I did not find any way of doing this differently). The only way which provided this information is iopending dtrace script. I need to be able to access the information it provides (or rather be able to implement its logic) in my C program. Usage of libdtrace is very cryptic (considering private API), as the overall dtrace business. Is there any example (besides a few I have found which don't answer my question - libdtrace buffered output and http://www.osdevcon.org/2008/files/osdevcon2008-petr.pdf) which can help me?

Community
  • 1
  • 1
DimaA6_ABC
  • 578
  • 4
  • 15
  • DTrace and libdtrace are all separate stuffs. which one are you talking about? – askmish Nov 04 '12 at 21:04
  • Don't forget to accept if it helped answer your question, and don't be afraid to comment if you want more information. Thanks! – Dan Jun 20 '13 at 07:15

1 Answers1

0

Using libdtrace directly can be a bit hairy since it's technically a private API, but you can find examples in other DTrace consumers. libdtrace is basically the same on all platforms that support it (Mac OS, Solaris, FreeBSD) and as a result the API is very stable. Solaris gets a few more updates, however, and IIRC Mac OS doesn't support all the features available on other platforms. However, this gives you more examples to work from.

You can either look at the source code of the dtrace command on one of those platforms, or you can look at the source code for some wrapper of the library such as node-libdtrace. I'd recommend the latter since it's just a wrapper that provides important high-level operations, which should make it simpler to figure out which code does what.

Dan
  • 7,155
  • 2
  • 29
  • 54