From owner-freebsd-hackers Wed Dec 8 8:33:53 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from c62443-a.frmt1.sfba.home.com (c62443-a.frmt1.sfba.home.com [24.0.69.165]) by hub.freebsd.org (Postfix) with ESMTP id 5A81B14D12 for ; Wed, 8 Dec 1999 08:33:50 -0800 (PST) (envelope-from adsharma@c62443-a.frmt1.sfba.home.com) Received: (from adsharma@localhost) by c62443-a.frmt1.sfba.home.com (8.9.3/8.9.3) id IAA29838; Wed, 8 Dec 1999 08:33:48 -0800 Date: Wed, 8 Dec 1999 08:33:48 -0800 From: Arun Sharma To: Andrzej Bialecki Cc: freebsd-hackers@freebsd.org Subject: Re: Fwd: Re: kstat - an API for gathering kernel stats Message-ID: <19991208083348.A29811@sharmas.dhs.org> References: <199911290505.VAA01931@c62443-a.frmt1.sfba.home.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.6i In-Reply-To: ; from Andrzej Bialecki on Mon, Nov 29, 1999 at 10:09:35AM +0100 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, Nov 29, 1999 at 10:09:35AM +0100, Andrzej Bialecki wrote: > > I was thinking about implementing SMP cpu stats using sysctl today and > > I have a question - can I create sysctl nodes dynamically ? > > > > i.e. > > > > for (cpu = 0; cpu < get_num_cpus(); cpu++) { > > /* create sysctl node here ? */ > > } > > Yes. See for example linux emulator or my SPY module: > > http://www.freebsd.org/~abial/spy > > You can also create whole new branches, as the second example shows. Thanks - that was useful. However, I noticed that only the leaves (SYSCTL_INT/LONG/STRING) etc can be dynamically created. But nodes can't be dynamically created. Am I correct ? I'm interested in doing something like: kern.stats.cpu0.idle kern.stats.cpu0.nice ... kern.stats.cpu1.idle kern.stats.cpu1.nice ... and I want the nodes cpu0, cpu1 etc dynamically created. But that's no big deal. I'll define 4 cpus for now and zero the values for non-existent cpus. -Arun To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message