in reply to Getting SNMPWalk to work with NetSNMP::agent

Why are you doing a NUMERIC comparison on OID's ?

The code should be:

if ( $oid lt new NetSNMP::OID("$rootOID.1.0") ) # << u +se "lt", not "<"
"use warnings;" would have caught that.
You also use "==" instead of "eq" in the next "elsif". Update What I meant was the other way around, but you got it.

             I hope life isn't a big joke, because I don't get it.
                   -SNL

Replies are listed 'Best First'.
Re^2: Getting SNMPWalk to work with NetSNMP::agent
by ebandook (Initiate) on Jun 04, 2012 at 22:16 UTC

    Thanks that worked ...
    I used the following code to get the SNMPWALK working :

    elsif ($mode == MODE_GETNEXT) { my $oidnum; if ( $oid lt new NetSNMP::OID("$rootOID.1.0") ) { $request->setOID("$rootOID.1.0"); my $count = `$perl $script 1`; $request->setValue(ASN_INTEGER, $count); } elsif ( $oid lt new NetSNMP::OID("$rootOID.2.0") ) { $request->setOID("$rootOID.2.0"); my $count = `$perl $script 2`; $request->setValue(ASN_INTEGER, $count); } elsif ( $oid eq new NetSNMP::OID("$rootOID.2.0") ) { $request->setOID("$rootOID.3.0"); my $count = `$perl $script 3`; $request->setValue(ASN_INTEGER, $count); } elsif ( $oid eq new NetSNMP::OID("$rootOID.3.0") ) { $request->setOID("$rootOID.4.0"); my $count = `$perl $script 4`; $request->setValue(ASN_INTEGER, $count); } elsif ( $oid eq new NetSNMP::OID("$rootOID.4.0") ) { $request->setOID("$rootOID.5.0"); my $count = `$perl $script 5`; $request->setValue(ASN_INTEGER, $count); } elsif ( $oid eq new NetSNMP::OID("$rootOID.5.0") ) { $request->setOID("$rootOID.6.0"); my $count = `$perl $script 6`; $request->setValue(ASN_INTEGER, $count); } elsif ( $oid eq new NetSNMP::OID("$rootOID.6.0") ) { $request->setOID("$rootOID.7.0"); my $count = `$perl $script 7`; $request->setValue(ASN_INTEGER, $count); } }