Peter, Answers in-line:
On Tuesday10 Aug, at 12:44 PM, Peter Taps wrote: > Folks, > > I have been going through some code samples on kstat. In the simplest case, > you open the kstat chain (kstat_open()), walk down the chain, and read values > (kstat_read). > > Is the data being collected during kstat_open() or during kstat_read()? If it > is getting collected during kstat_open, it must be collecting ALL the > counters whether or not the user needs them. This must be > performance-expensive. If it is getting collected during kstat_read, it is > collecting only one counter at a time, making it performance-inefficient. Data is only collected during the kstat_read() and then only for the kstat specified in the arguments. Performance for kstat_read() is reasonably good since it will update all the counters for the kstat, rather just piece-meal. > I don't need all the data. Just some counters on CPU and disk. Is there a way > to inform kstat upfront on the names of counters that need to be collected? There are two strategies (at least), the first being a sample loop which performs a kstat_lookup() for all the kstats that you are interested in and then kstat_read() them. The advantage to this strategy is that some kstats can be ephemeral ( CPUs go offline, disk can go offline, memory can be DR'ed out, etc ). The disadvantage is that kstat_lookup() is linear search. The other strategy is to keep a collection of all the kstat's that you are interested in and periodically check them to make sure they are still "fresh". Kstat_read() fits the bill quite nicely, as it will error when it tries to read data for a kstat which is no longer available. Obviously there is somewhat more to it than that, but that's a brief introduction. > Another related question. I need to continuously collect data on a 30 second > interval. What is the best way to achieve this? Have you looked at the kstat(1M) and Kstat(3PERL)? The kstat command is written in perl and you may either be able to use it "as is" or adapt it to your purposes. Kstat(3PERL) is a Solaris extension to Perl which provides native access to kstat data. I've got a working python prototype if python is your bag, however I've yet to get it integrated into Solaris. If perl or python aren't what you are looking for, it's reasonably simple to write a kstat collection program in C and I would be happy to help you with that. Best, Erik --- Erik O'Shaughnessy Austin, TX 512-401-1070 erik.oshaughne...@oracle.com _______________________________________________ observability-discuss mailing list observability-discuss@opensolaris.org