monitoringsolarisquery-performanceprocfsiostat

Sun Solaris 10/11: get disk i/o rates in machine readable way


I need to get the I/O rates of the disks/drives on Sun Solaris 10 and 11.

There is the command-line tool "iostat" which returns exactly what I need. But this output is formatted and not in a clean machine readable way.
Beside this, I don't want to execute binary out of the java-program in which I need this information.

In Linux there is /proc/diskstats which does a good job. But on Solaris such mechanism seems not to be supported.

I actually have not much clue about Solaris in general. Searches through the internet didn't got me some hints about how to get the disk i/o (besides command-line tools like iostat, sar, ... (e.g. https://docs.oracle.com/cd/E23824_01/html/821-1451/spmonitor-4.html))

Thanks for any help!


Solution

  • Solaris doesn't use /proc for statistics. Solaris statistics are provided by the kernel statistic facility via ioctl() calls on /dev/kstat. You can use the kstat command to view them and you can run kstat -l to list the available statistics.

    To see how to access kstats directly from Java, see this: http://www.petertribble.co.uk/Solaris/jkstat.html:

    JKstat

    JKstat provides a jni interface for Java applications to access Solaris kstats.

    If you want to know how Solaris tools such as iostat work, you can browse the (now old) OpenSolaris repository at Illumos.org, or you can run the command under truss to see what system calls it makes.

    And if you really want to get deep into observing everything that's happening and how it's happening on Solaris, look into dtrace. With dtrace you can not only know how many IO operations are done on each disk, you can get details from every one of them such as the number of bytes and where on the disk it was written to/read from.