开发者

Can't get Extended SNMP output in Perl

I have written a Perl script to put back some SNMP values, which works fine. I have now written a script on the remote server and used the extend function in SNMP to put the value from the script into SNMP.

If I run:

snmpget -v2c -c public 10.0.0.10 'NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."cc_power"'

I get the result:

NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."cc_power" = STRING: 544

But when I try to use my script to get the information back it doesn't get it. Here is the script:

#!/usr/bin/perl     

use strict;
use SNMP;
use RRDs;

my $rrd_db = "/storage/db/rrd/cc_power.rrd";

my $sess;
my $val;
my $error;

$sess = new SNMP::Session(DestHost => "10.0.0.10", Community => "public", Version => 2);
my $power = $sess->get('NET-SNMP-EXTEND-MIB::nsExtendOutput1Line.\"cc_power\"');

$error=RRDs::error;
die "ERROR while updating RRD: $error\n" if $error;

my $date=time;
print "Da开发者_运维问答ta Script has been run - Output: ${date}:${power}\n";

but nothing is returned, and I have no idea why... no errors or anything, have I missed something stupid?

Hope someone can help as this is driving me nuts :)


I assume that you used netsnmp snmpget. Well, it hides too many details from you, as it loads MIB documents in background and nicely translate OIDs and SNMP values to all kinds of user friendly formats.

So next time pay attention to what decoration it performs and simulate that in your own code to achieve the same effects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜