New experimental statistics collector in master

Matthew Dillon dillon at
Sat Jul 29 22:54:42 PDT 2017

Master now has an in-kernel statistics collector which is enabled by
default, and a (still primitive) userland program to access it.  This
recorder samples the state of the machine once every 10 seconds and records
it in a large FIFO, all in-kernel.  The FIFO typically contains 8192
entries, or around the last 23 hours worth of data.

Statistics recorded include current load, user/sys/idle cpu use, swap use,
VM fault rate, VM memory statistics, and counters for syscalls, path
lookups, and various interrupt types.  A few more useful counters will
probably be added... I'd like to tie cpu temperature, fork rate, and exec
rate in at some point, as well as network and disk traffic.

The statistics gathering takes essentially no real overhead and is always
on, so any user at the spur of the moment with no prior intent can query
the last 23 hours worth of data.


There is a user frontend to the data called 'kcollect' (its tied into the
buildworld now).  Currently still primitive.  Ultimately my intention is to
integrate it with a dbm database for long-term statistical data retention
(if desired) using an occasional (like once-an-hour) cron-job to soak up
anything new, with plenty of wiggle room due to the amount of time the
kernel keeps itself.  This is better and less invasive than having a
userland statistics gathering script running every few minutes from cron
and has the advantage of giving you a lot of data on the spur of the moment
without having to ask for it before-hand.

If you have gnuplot installed (pkg install gnuplot), kcollect can generate
some useful graphs based on the in-kernel data.  Well, it will be boring if
the machine isn't doing anything :-).  There are options to use gnuplot to
generate a plot window in X or a .jpg or .png file, and other options to
set the width and height and such.  At the moment the gnuplot output uses a
subset of statically defined fields to plot but ultimately the field list
it uses will be specifiable.

Sample image generated during a synth run:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Users mailing list