I was working on a custom SNMP-Mib, and I leaned against the wall, trying to get the agent to return the correct data.
MIB (confirmed by running smilint -l 6 ):
IDB-MIB DEFINITIONS ::= BEGIN IMPORTS MODULE-IDENTITY, OBJECT-TYPE, Integer32, enterprises FROM SNMPv2-SMI MODULE-COMPLIANCE, OBJECT-GROUP FROM SNMPv2-CONF; idb MODULE-IDENTITY LAST-UPDATED "201307300000Z"
Agent File:
#!/usr/bin/perl use NetSNMP::OID(':all'); use NetSNMP::agent(':all'); use NetSNMP::ASN(':all'); sub myhandler { my ($handler, $registration_info, $request_info, $requests) = @_; print "Handling request\n"; for ($request = $requests; $request; $request = $request->next()) {
When I start the agent, I get the following:
Running new agent Starting subagent! Registering agent with oid idb Agent registered
So, I know a lot works. However, when I run the following command:
snmpget -v 1 -c mycommunity localhost:161 test2.0
I get this error message:
Error in packet Reason: (noSuchName) There is no such variable name in this MIB. Failed object: IDB-MIB::test2.0
I know from snmptranslate that the mib file is installed correctly. I even looked at debug for snmpget (using -DALL) to make sure mib loads and parses correctly.
So my question is: why did my subagent not pass the request?
Update:
I was told by @EhevuTov that my MIB file is not valid, however smilint does not report any problems, and running snmpget -v 2c -c mycommunity localhost:161 .1.3.6.1.4.1.42134.3.0 correctly reports the NAME of the object (IDB- MIB :: test2.0) but does not find any data for it.
I get IDB-MIB::test2 = No Such Object available on this agent at this OID , which makes me think that my agent is not registering properly, however it does not throw any errors.
Update 2:
I was looking a bit for agent code. Based on the CPAN documentation ( http://metacpan.org/pod/NetSNMP::agent ), it seems that calling the $agent->register function should return 0 if successful. So I checked the return code and got the following:
Agent registered. Result: NetSNMP::agent::netsnmp_handler_registration=SCALAR(0x201e688)
A listing using Data::Dumper results in:
$VAR1 = bless( do{\(my $o = 34434624)}, 'NetSNMP::agent::netsnmp_handler_registration' );
I dimly understand what the blessing does, but even then I have no idea what this result means. So I'm starting to think that the agent is somehow wrong. Does anyone know how to debug these agents? Somewhere I can see if the snmpd wizard loads correctly?