From owner-freebsd-arch@FreeBSD.ORG Fri Jan 21 14:05:58 2011 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4102C1065674; Fri, 21 Jan 2011 14:05:58 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail03.syd.optusnet.com.au (mail03.syd.optusnet.com.au [211.29.132.184]) by mx1.freebsd.org (Postfix) with ESMTP id B850C8FC0A; Fri, 21 Jan 2011 14:05:57 +0000 (UTC) Received: from c122-106-165-206.carlnfd1.nsw.optusnet.com.au (c122-106-165-206.carlnfd1.nsw.optusnet.com.au [122.106.165.206]) by mail03.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p0LE5shi021429 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 22 Jan 2011 01:05:55 +1100 Date: Sat, 22 Jan 2011 01:05:54 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Oliver Fromme In-Reply-To: <201101201059.p0KAxHgn053963@lurza.secnetix.de> Message-ID: <20110122005919.W14506@besplex.bde.org> References: <201101201059.p0KAxHgn053963@lurza.secnetix.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: mdf@freebsd.org, freebsd-arch@freebsd.org Subject: Re: Weed-whacking sysctl(8) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jan 2011 14:05:58 -0000 On Thu, 20 Jan 2011, Oliver Fromme wrote: > mdf@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