Perl Net::SNMP returns noSuchName when snmpwalk works -
I'm new to perl, but I'm trying to write plug-ins for nagios. I have a simple request that is unsuccessful, but if I try the same request with snmpwalk it works.
My code is:
#! Use / usr / bin / perl -w hard; Net :: SNMP; My $ host = '10.10.10.203 '; My $ community = 'myComm'; My $ session; My $ error; My $ reaction = bottom; ($ Session, $ error) = Net :: SNMP-> Sessions (-hostname => host $ -Vijon = 2; -community = & gt; $ community, -port => 161, -timeout = & gt; 20); My $ uptimeOID = '1.3.6.1.2.1.1.3.0'; My $ myOID = '1.3.6.1.4.1.7 933'; If (define ($ response = $ session-> get_request ($ myOID))) {if ($ session-> error_stats == 2} {my $ sessionError = $ session- & gt; Error; Print ("($ session error) OID is not supported ($ myOID). \ N"); }} And {print ("$ response"); }
If I run this script then it will fail to say no name, but if there are any runs:
snmpwalk -v 2c -c myComm 10.10.10.203 1.3. 6.1.4.1.7933
I get the feedback I need. Does anyone know why it does not work?
If I check the uptime OID with this script then it should work as it should.
You have already recognized that through the command line you can not "meet" Walking "If there is a specific value that you want to" get "in your script, then enter the full OID to identify the target.
There is something in a table record that you probably want to get (and all this is actually tabulated in FASTTRAKIDERAID-MIB), so getting a simple is not enough. snmpwalk.pl
script that comes with Net :: SNMP
or look for if you see SNMP :: Util
you can easily provide functionality.
Comments
Post a Comment