do we have a Perl interface to sysctl(3)?
Is there an (OpenBSD) perl interface to sysctl(3)? Parsing the output of `sysctl $string` works, but is clumsy. 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. Rex::Commands::Sysctl looks like it could work... but browsing the source code reveals that internally it just does `sysctl $string` and parses the result. What do OpenBSD people use for doing system-monitoring from Perl? ciao, -- -- Jonathan Thornburg [remove -animal to reply] jth...@astro.indiana-zebra.edu Dept of Astronomy, Indiana University, Bloomington, Indiana, USA C++ is to programming as sex is to reproduction. Better ways might technically exist but they're not nearly as much fun. -- Nikolai Irgens
Re: do we have a Perl interface to sysctl(3)?
On Mon, Jan 14, 2013 at 1:16 AM, Jonathan Thornburg jth...@astro.indiana.edu 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. So, uh, what fails if you try to build it? Philip Guenther
Re: do we have a Perl interface to sysctl(3)?
Philip Guenther guent...@gmail.com writes: On Mon, Jan 14, 2013 at 1:16 AM, Jonathan Thornburg jth...@astro.indiana.edu 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. So, uh, what fails if you try to build it? cpan output [...] OS unsupported (openbsd). Here's a nickel, go buy yourself a real OS. [..] Dunno why they stripped kid from this sentence, the meaning wouldn't have been much altered. 8) -- Jérémie Courrèges-Anglas GPG Key fingerprint: 61DB D9A0 00A4 67CF 2A90 8961 6191 8FBF 06A1 1494
Re: do we have a Perl interface to sysctl(3)?
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, -- -- Jonathan Thornburg [remove -animal to reply] jth...@astro.indiana-zebra.edu Dept of Astronomy IUCSS, Indiana University, Bloomington, Indiana, USA on sabbatical in Canada starting August 2012 Some languages give you enough rope to hang yourself with. Perl gives you the rope, the scaffold, and the trapdoor under your feet... plus a loaded gun and a vial of poison, because hey, 'there's more than one way to do it'... -- Eryq Hughes
Re: do we have a Perl interface to sysctl(3)?
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