Thomas Maier-Komor schrieb:
I also iterate only once and search for the modules/classes of interest.
Why do you use strncmp? Are ks_module and Co not guaranteed to be null
terminated or did you mix it up with ks_name which includes the trailing id?

Maybe just a leftover from an earlier implementation which iterated over ksp->ks_name. strcmp() should be sufficient - the strings are null terminated.


Interesting experience - thanks for sharing it. I'd like to know if the
behavior concerning system_misc has improved with later Solaris releases...

Well, in Solaris 2.6 it took 2-3 seconds to read system_misc on a machine with 32GB RAM and ~600 MHz CPUs. I skipped Solaris 7 and in 8 the problem went away - so I don't know if it has been fixed in 7 or 8. The statistics in system_misc were sometimes even unusable (pp_kernel had ridicilous high values). Therefor I added some comments in the source code:

/*
 * Zugriff auf system_pages braucht extrem viel Zeit (>1s bei 32 GB RAM).
 * Gibt es nicht etwas besseres?
 */
  if((ksp = kstat_lookup(kc, "unix", -1, "system_pages")) == NULL)
    return;
  if(!kstat_read(kc, ksp, NULL))
    return;
  pp->kmem = data_lookup(kc, ksp, "pp_kernel") * pagesize;

/* Bug in älteren Solaris-Versionen */
  if(pp->kmem > totalmem)
    pp->kmem = 0;



Some other things you should consider (I fell into these traps while writing my little program):

. altough the network drivers do have 64 bit counters in addition to
  the 32 bit ones (obytes64, opackets64, rbytes64, ipackets64) - at
  least for the bge driver these counters are still 32 bit values, so
  they wrap at 2^32. So don't rely on these values really 64 bits wide.
. If you do DR operations or add/remove disks you have to kstat_close()
  kstat_open() again - otherwise you won't notice the changed configuration.
. Also DR: Remember that on large machines if you detach a system board
  some cpu_stat%d entries might vanish.
. If you count disk usage remember that SDS/SVM also registers its
  devices to kstat. In my program I did calculate a disk I/O summary over
  all disks and I wondered why on some machines these values were doubled
  or 2.5x:
  They were setup with SDS while other machines had VxVM (no kstat)
  installed.
. Same goes for disk/partition kstat classes: don't count disk I/O twice.
  Basically the relevant portion looks like:

  for(ksp = kc->kc_chain; ksp != NULL; ksp = ksp->ks_next)
  {
    if(ksp->ks_type != KSTAT_TYPE_IO)
      continue;
    if(!strcmp(ksp->ks_module, "md"))
      continue;
    if(!strcmp(ksp->ks_class, "partition"))
      continue;
    kstat_read(kc, ksp, &kio);
    pp->rops += kio.reads;
    pp->wops += kio.writes;
    pp->rbytes += kio.nread;
    pp->wbytes += kio.nwritten;
  }





Daniel
_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to