add new mib master agent [closed]
Asked Answered
H

5

6

I was following instructions on the net-snmp website to add my own MIB support to the master agent.

Here is what I did:

  1. I created my support .c and .h file in net-snmp/agent/mibgroup/ folder.
  2. I copied my MIB file to /usr/local/share/snmp/mibs/ folder.
  3. I ran "./configure --with-mib-modules="myMib" "
  4. I ran "make" and "make install"
  5. I started snmpd with "snmpd -f -Le -d -c snmpd.conf &"
  6. I can see my MIB structure by running snmpdtranslte command. However, when I try to use snmpget -v2c -c public "MY-MIB-FILE::myVariable", I keep getting "*** = No such object available on this agent at this OID".

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.

Hayton answered 27/3, 2012 at 22:43 Comment(6)
Have you already tried to add some traces in your agent? This is where I start from. Put fprintf's in each step of you agent loading and handlers to see where it stops to respond. Without it, we'd have too may possibilities...Loess
Yes, I tried the trace. Everything looks good and there is no errors. I can see the command gets send out and the "NO such object" response is coming back, which is error code 8.Hayton
Maybe this is relevant, I am attaching my MIB file under netSnmpExamples because I don't have a company OID. So in my MIB file I have this section: xxxsnmp MODULE-IDENTITY LAST-UPDATED "201112220000Z" ORGANIZATION "www.xxx.com" CONTACT-INFO "email: [email protected]" DESCRIPTION "Testing my mib" REVISION "201112200000Z" DESCRIPTION "First draft" ::= { netSnmpExamples 5 }Hayton
You said you put traces, but didn't give any details. Are you sure your agent "init_*()" function is beeing called? This tutorial is really straightfoward and is expected to work almost "out of the box". I think you must be missing a detail, but can't help with no further information. Can you please edit your question adding a detailed step-by-step of what you've done?Loess
fljx, I got the trace and everything looks good. I can see the debug messages and I traced it all the way to where it sends out the "snmpget" request. But then I couldn't see any debug messages of how netsnmp handle the request. I did both ldd and nm on snmpd but I don't see my init_*() function. That's why I was asking how to make sure the init_*() function is compiled into snmpd in my reply to Andrew below. I think the steps I listed above is exactly what the tutorial is doing. I can try to post the trace here. But I don't think it is going to help.Hayton
Check the configure output and Makefile contents to be sure your sources are being included. Furthermore, your commandline is just ./configure --with-mib-modules="myMib"? No other flags? Might I ask you to put all your agent source code somewhere I can download and test in my own machine (the [email protected] would be fine).Loess
M
7

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.

Mirabella answered 3/4, 2012 at 3:32 Comment(2)
Andrew, It seems like my init_x() is not compiled into snmpd. But I did use ./configure --with-mib-modules="myMib". Do you know how to make sure my init_x() is compiled into snmpd?Hayton
I am attaching my MIB under netSnmpExamples. I am use netSnmpExamples.5 as my OID. I don't know if this is the problem.Hayton
P
3

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.

Pledge answered 24/6, 2015 at 10:27 Comment(0)
S
2

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.

Swirly answered 31/3, 2012 at 16:42 Comment(2)
Appleman, I believe I add the configuration changes in snmpd.conf file. I do have the ".0" at the end when I use "snmpget" and "snmpset". I will try your suggestion in explicitly specifying host and ports.Hayton
I am attaching my MIB under netSnmpExamples. I am using netSnmpExamples.5 as my MIB OID.Hayton
S
1

ldd worth checking out, in my case snmpd was dynamically linked with standard Ubuntu libnetsnmpmibs.so and I didn't get custom MIB support though also followed the same tutorial.

Repaired dynamic linking stuff and everything worked out!

Stanislaw answered 25/12, 2014 at 15:9 Comment(0)
P
-1

snmpd.conf

  view  systemonly  included  .1.3.6.1.4.1.8072.2.4.1.1.1
Photoelectric answered 16/1, 2017 at 18:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.