Weed-whacking sysctl(8)

Bruce Evans brde at optusnet.com.au
Fri Jan 21 14:05:58 UTC 2011


On Thu, 20 Jan 2011, Oliver Fromme wrote:

> mdf at freebsd.org wrote:
> > As bde@ mentioned, there's very little actual use of the sysctl format
> > strings.  I recently changed it so the use is even smaller, but I've
> > got a quandary as to how to finish the job.
> >
> > I agree with Bruce that the formatted structs can just be removed.
>
> Will that break scripts that use sysctl(8) for monitoring,
> logging and similar tasks (vm.loadavg for example)?
>
> I've installed such scripts at a few customers' sites over
> the past years.  It would be somewhat unfortunate if they
> break when the admins at those sites decide to update the
> OS.

Yes, we shouldn't break the old formatting immediately.

> PS:  Personally I like the format very much, because it's
> easy to use in shell scripts.  For example, when you write
>
> set $(sysctl -n vm.loadavg)
>
> then you have the three values in $2, $3 and $4.
> Another phrase I've used in scripts quite often is this:
>
> X=$(sysctl -n kern.boottime)
> echo ${X#*\}}
>
> There are other ways to get that piece of information, but
> they're more complicated and/or less efficient.

You are a better shell programmer than most :-).  I couldn't write the
${X# expansion without looking it up, and would normally use much larger
awk code.

Bruce


More information about the freebsd-arch mailing list