[Wellington-pm] Looking for an easier, clearer way to ...
michael at diaspora.gen.nz
michael at diaspora.gen.nz
Sat Sep 4 20:23:15 CDT 2004
>I'm sure there must be an easier, clearer way to do this;
>
>my $diskdescr =
> `snmpwalk $hostname -c $communityname -Oqs -v1 extOutput`;
>chomp $diskdescr;
Backticks always make me nervous. I probably would have written that
as the much longer, but safer and one less process (no /bin/sh involved):
my $fh;
open $fh, "-|", "snmpwalk", $hostname, "-c", $communityname, qw(-Oqs -v1 extOutput);
my $diskdescr = <$fh>; chomp $diskdescr;
In terms of a native Perl solution, I had a quick look at Net::SNMP,
but it assumes far too good a knowledge of SNMP to expose such useful
functions. A quick look on search.cpan.org says that SNMP::Util has
a walk function, but requires the ucdsnmp package to be installed,
and then SNMP.pm.
-- michael.
More information about the Wellington-pm
mailing list