Subject: libkvmstats???
To: None <tech-kern@NetBSD.ORG>
From: Brian C. Grayson <bgrayson@ece.utexas.edu>
List: tech-kern
Date: 02/03/1998 12:40:41
  I'm currently working on adding support for interrupt
statistics to xosview-1.5.2, and I'm thinking there has to be a
better way of getting kernel statistics than doing the kernel
munging that vmstat does for interrupts, and what pstat (used to
do) for swap, and what netstat does for packets, and what vmstat
does for disks...

  Has anyone thought about adding a new library, like
libkvmstats, that would contain a nice sysctl()/swapctl()-like
interface to kernel statistics?  Then our code to some of the
various system utilities, and other third-party programs like
top and xosview, wouldn't contain as much direct kernel-munging
that has to be changed when the kernel internals change (like the
swap stuff, which required changes to all sorts of utilities).  

  Yes, there would be a lot of judgment calls as far as what
statistics should be returned.  Maybe each statisic could have
an ``overall'' and a ``detailed'' version.  For xosview, I
simply use things like ``total bytes in or out of all
interfaces in the ifnet list,'' or ``total disk I/O in bytes.''
Supporting the statistics used by top's top three lines and
utilities like xosview would at least provide a starting point.

  Besides hiding internal-change things like the new swap code,
having such a library would also help hide machine-dependent
stuff, like the fact that for the pc532, interrupt statistics
are kept differently.  Without such a library, for example,
every interrupt-statistic utility program (all two of them)
needs to have ifdefs and special code for pc532 -- unnecessary
code duplication!  Such a library, especially if also supported
by the other BSDs (and even Lin*x), would also make porting
apps and backwards compatibility easier on a few of us...  :)

  Alternatively, I guess sysctl could be extended to provide
these features, or a series of diskctl/intctl/... like swapctl.
(Why was swapctl() not just added as another sysctl?)

  I'll be the first to admit I do not (yet) have the know-how
to do such stuff.  Or at least I'm sure anything I did would
need to be massaged a lot to make it source-tree-worthy.

  Thanks for your patience.  Commence firing to shoot my idea
down!  :)

  Brian
-- 
Brian Grayson (bgrayson@ece.utexas.edu)
Graduate Student, Electrical and Computer Engineering
The University of Texas at Austin
Office:  ENS 406       (512) 471-8011
Finger bgrayson@orac.ece.utexas.edu for PGP key.