On Tue, 15 Jan 2013, Jonathan Thornburg wrote:
> I wrote
>
> | FreeBSD has the BSD-Sysctl perl module available from CPAN, which would
> | be ideal for my purposes... except that it doesn't (yet) support OpenBSD.
>
> On Mon, 14 Jan 2013, Philip Guenther wrote:
> > So, uh, what fails if you try to build it?
>
> % uname -a
> OpenBSD cobalt.astro.indiana.edu 5.1 GENERIC.MP#1 amd64
> % pwd
> /usr/local/perl-modules/BSD-Sysctl-0.10
> % head -13 README
> This file is the README for BSD::Sysctl version 0.10
>
> INSTALLATION
>
> perl Makefile.PL
> make
> make test
> make install
>
> Building this module requires a FreeBSD system and a C compiler.
> Support for OpenBSD and NetBSD will appear in future releases. In
> theory, this module should be able to handle any system that uses
> a sysctl interface to the kernel.
> % perl Makefile.PL
> OS unsupported (openbsd). Here's a nickel, go buy yourself a real OS.
> %
>
> Notes:
> * As of yesterday, 0.10 is the latest version of BSD::Sysctl on CPAN.
> * I'm well aware that OpenBSD 5.2 has been out for a while; I bought a
>   CD.  If and when 5.1 proves inadequate for my needs, I'll reinstall.
>   If not, I'll wait for 5.3.
>
> ciao,

I would have to look at the Perl module, however I am guessing that part of 
this may be due to how FreeBSD et al handle their sysctls - there is 
a "magic" sysctl that allows you to ask the kernel to give you the OID for a 
given name, then you can go back and request the OID (yes, you get the 
potentially racy behaviour for free). NetBSD does things differently again 
(you have to ask for parts of the MIB and then walk/parse that). With OpenBSD 
you currently have to know the OID number that you want.

You might be interested in checking out Go (golang.org and in ports), which 
has a functional and cross-platform sysctl mechanism:

package main

import (
        "fmt"
        "syscall"
)

func main() {
        version, _ := syscall.Sysctl("kern.hostname")
        ncpu, _ := syscall.SysctlUint32("hw.ncpu")

        fmt.Printf("%s has %d CPU(s)\n", version, ncpu)
}

-- 

    "Reason is not automatic. Those who deny it cannot be conquered by it.
     Do not count on them. Leave them alone." -- Ayn Rand

Reply via email to