I was following instructions on the net-snmp website to add my own MIB support to the master agent.
Here is what I did:
I did exactly what the tutorial says, and I can run snmpget
and snmpset
on the NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject
example.
Please help me understand what I missed here.
The "No such object available on this agent at this OID" indicates that, as far as netsnmpd is concerned, there is no corresponding OID in its tree.
Don't get confused by the success of snmptranslate
. Snmptranslate only operates on the MIB files themselves and doesn't require access to an snmp server at all. So the fact that snmptranslate shows your MIB details correctly is just an indication that your mib is correctly copied to $MIBDIRS
or the directories listed in your .snmp/snmp.conf
file (etc.).
Assuming that you're following the tutorial, the mib that you have implemented provides a single scalar variable. Scalar variables are given an index (ie. suffix) of .0
. Try running either of the following commands:
snmpget -v2c -c public MY-MIB-FILE::myVariable.0
Or:
snmpwalk -v2c -c public MY-MIB-FILE::myVariable
The latter will give you a list of all of the MIB leaves under that OID, which (in your case) will include the .0
node.
If that fails it is worth ensuring that your code is being compiled in and is executing correctly.
For a start, check the details at the end of the ./configure
step to make sure that the summary includes your mib. eg. (result from ./configure --with-mib-modules="nstAgentModuleObject"):
---------------------------------------------------------
Net-SNMP configuration summary:
---------------------------------------------------------
SNMP Versions Supported: 1 2c 3
Net-SNMP Version: 5.4.1
Building for: linux
snip
Agent MIB code: nstAgentModuleObject default_modules => snmpv3mibs mibII ucd_snmp notification notification-log-mib target agent_mibs agentx disman/event disman/schedule utilities host
snip
---------------------------------------------------------
For the former, you can run nm
over the snmpd executable agent/.libs/libnetsnmpmibs.so
file and make sure that the init_X()
function that corresponds to your MIB is present. It's also worth making sure that the init_nstAgentModuleObject()
function is present. If you're running make install
before testing it is worth ensuring (using ldd
) that the libnetsnmpmibs.so library that is being used is the one that you've just built, and that you don't have a path problem.
You can use the built in debug messaging system by adding DEBUGMSGTL()
calls within your init_X()
function. To see the debug messages add a -DALL
option on your snmpd command line.
The message No Such Object available on this agent at this OID
occurs when the agent does not support the requested MIB object at all or when the index or instance variable isn't specfied.
From the tutorial you linked to , did you add the relevant configuration for the community string public ?
E.g
By running snmpconf as detailed here.
Also see the configuration changes mentioned in the Beginner and Debugging Tips section here.
You also don't seem to have the index or instance specified for your variable it should be like
snmpget -v2c -c public MY-MIB-FILE::myVariable.0
.
You may want to also try explicitly specifying the host and port that your master agent runs on in case it isn't in snmpd.conf
.
Try to start your agent from build directory. net-snmp-x.x.x/agent.
./snmpd -f -L -d -c /usr/local/etc/snmpd.conf
And stop all other SNMP agents.
In my case if I run
snmpd -f -Le -d -c snmpd.conf &
this command start preinstalled snmp daemon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With