Outside with dtrace
, there is no way to get the statistics when they are updated however, the C libkstat API allows retrieving kstat
statistics with an arbitrary sub second sampling rate.
There is also a perl api should you want to do it with scripting.
A very simple way to use it would be to create a customized kstat
command (which happen to already be a perl script leveraging the kstat perl api) and modify it to use high resolution timers instead of the default one, e.g.:
$ sed '
s/sleep($interval);/Time::HiRes::usleep($interval*1000.);/
/use Sun::Solaris::Kstat/a\
use Time::HiRes;
' /usr/bin/kstat > /var/tmp/kstat_ms
$ chmod +x /var/tmp/kstat_ms
$ /var/tmp/kstat_ms -n lo0 500 3
module: lo instance: 0
name: lo0 class: net
crtime 19.559031813
ipackets 532
opackets 532
snaptime 4309.506435597
module: lo instance: 0
name: lo0 class: net
crtime 19.559031813
ipackets 534
opackets 534
snaptime 4310.008578348
module: lo instance: 0
name: lo0 class: net
crtime 19.559031813
ipackets 536
opackets 536
snaptime 4310.511617682