添加新的MIB主代理 [英] add new mib master agent

查看:87
本文介绍了添加新的MIB主代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在遵循在线snmp网站上的说明将我自己的MIB支持添加到主代理.

这是我所做的:

  1. 我在net-snmp/agent/mibgroup/文件夹中创建了.c和.h支持文件.
  2. 我将MIB文件复制到了/usr/local/share/snmp/mibs/文件夹中.
  3. 我运行了"./configure --with-mib-modules =" myMib"
  4. 我运行了"make"和"make install"
  5. 我从"snmpd -f -Le -d -c snmpd.conf&"开始snmpd.
  6. 我可以通过运行snmpdtranslte命令来查看我的MIB结构.但是,当我尝试使用 snmpget -v2c -c public"MY-MIB-FILE :: myVariable",我不断得到"*** =没有这样的对象 在这个OID上的这个代理商上."

我完全按照本教程中的说明进行操作,并且可以在NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject示例中运行snmpgetsnmpset.

请帮助我了解我在这里错过的事情.

解决方案

在此OID上此代理上没有可用的此类对象"指示,就netsnmpd而言,其树中没有相应的OID. /p>

不要对snmptranslate的成功感到困惑. Snmptranslate仅对MIB文件本身进行操作,根本不需要访问snmp服务器.因此snmptranslate可以正确显示您的MIB详细信息这一事实仅表明您的mib已正确复制到$MIBDIRS.snmp/snmp.conf文件中列出的目录(等).

假设您正在学习本教程,则已实现的mib提供了一个标量变量.标量变量的索引(即后缀)为.0.尝试运行以下任一命令:


snmpget -v2c -c public MY-MIB-FILE::myVariable.0

或者:


snmpwalk -v2c -c public MY-MIB-FILE::myVariable

后者将为您提供该OID下所有MIB叶子的列表,(在您的情况下)将包括.0节点.

如果失败,则值得确保您的代码已在其中编译并正确执行. 首先,请检查./configure步骤末尾的详细信息,以确保摘要中包含您的mib.例如. (来自./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
---------------------------------------------------------

对于前者,您可以在 snmpd可执行文件 agent/.libs/libnetsnmpmibs.so文件上运行nm,并确保存在与您的MIB相对应的init_X()函数.确保存在init_nstAgentModuleObject()函数也是值得的.如果在测试之前运行make install,则值得确保(使用ldd)正在使用的libnetsnmpmibs.so库是您刚刚构建的库,并且没有路径问题

您可以通过在init_X()函数中添加DEBUGMSGTL()调用来使用内置的调试消息系统.要查看调试消息,请在snmpd命令行上添加-DALL选项.

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.

解决方案

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.

这篇关于添加新的MIB主代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆