snmpget:此OID上此代理上没有此类对象可用

snmpget:此OID上此代理上没有此类对象可用,snmp,net-snmp,snmpd,Snmp,Net Snmp,Snmpd,根据本教程,我正在尝试将自己的MIB模块添加到snmp代理中: 现在,我按照教程一步一步地检查所有内容,搜索了很长时间,但没有任何东西帮我解决问题 我使用的是网络snmp版本5.7.3 我在net snmp/agent/mibgroup目录中实现了以下代码: #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/ne

根据本教程,我正在尝试将自己的MIB模块添加到snmp代理中: 现在,我按照教程一步一步地检查所有内容,搜索了很长时间,但没有任何东西帮我解决问题

我使用的是网络snmp版本5.7.3

我在net snmp/agent/mibgroup目录中实现了以下代码:

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "nstAgentModuleObject.h"

/*
* the variable we want to tie an OID to.  The agent will handle all
** GET and SET requests to this variable changing it's value as needed.
*/

static long nstAgentModuleObject = 42;

/*
* our initialization routine, automatically called by the agent 
* (to get called, the function name must match init_FILENAME()) 
*/
void
init_nstAgentModuleObject(void)
{
static oid      nstAgentModuleObject_oid[] =
    { 1, 3, 6, 1, 4, 1, 8072, 2, 4, 1, 1, 1, 0 };

/*
 * a debugging statement.  Run the agent with -DnstAgentModuleObject to see
 * the output of this debugging statement. 
 */
DEBUGMSGTL(("nstAgentModuleObject",
            "Initializing the nstAgentModuleObject module\n"));


/*
 * the line below registers our variables defined above as
 * accessible and makes it writable.  A read only version of any
 * of these registration would merely call
 * register_read_only_int_instance() instead.  The functions
 * called below should be consistent with your MIB, however.
 */

DEBUGMSGTL(("nstAgentModuleObject",
            "Initalizing nstAgentModuleObject scalar integer.  Default value = %d\n",
            nstAgentModuleObject));

netsnmp_register_long_instance("nstAgentModuleObject",
                              nstAgentModuleObject_oid,
                              OID_LENGTH(nstAgentModuleObject_oid),
                              &nstAgentModuleObject, NULL);

DEBUGMSGTL(("nstAgentModuleObject",
            "Done initalizing nstAgentModuleObject module\n"));
}
现在,使用指定的OID运行snmpget会产生此错误(在末尾附加一个0,因为它是标量。没有标量也会导致相同的错误)

似乎MIB模块没有正确地内置到代理中,但我想不出原因

我知道同样的问题以前也在这里发布过,但没有得到任何答案。(
所以我想试试我的运气,希望有人能帮我

我也有同样的问题, 它与5.6.2不兼容

我是如何解决的:

我已经升级到5.7.3,然后它开始工作。 您需要注意以下事项:

  • 使用--with mib modules=agentx配置包(在构建时)以支持agentx 这是我的配置:

      ./configure --prefix=/usr --build=i386-linux --host=arm-linux --target=arm-linux --with-ar=arm-arago-linux-gnueabi-ar --with-cc=arm-arago-linux-gnueabi-gcc --with-ld=arm-arago-linux-gnueabi-ld --with-cflags="-O3 -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp" --with-endianness=big --with-ldflags=-Bstatic --enable-mini-agent --with-mib-modules="mibII ip-mib if-mib tcp-mib udp-mib ucd_snmp target agent_mibs notification-log-mib snmpv3mibs notification agentx" --without-openssl --without-perl-modules --disable-embedded-perl --disable-shared --with-default-snmp-version="2" --with-sys-contact="root" --with-sys-location="unknown" --with-logfile="/var/log/snmpd.log" --with-persistent-directory="/var/net-snmp" --disable-manuals
    
  • 将agentx添加到snmpd.conf 这是我的snmpd.config

    master  agentx
    
    rocommunity public rwcommunity private
    
    com2sec readonly  default         public 
    com2sec readwrite default     private
    
  • 已使用调试启动snmpd,以提供更多详细信息:

    snmpd -f -Lo: -Dagentx
    
  • 然后启动agentx应用程序

  • 以下教程也有帮助:


    代理是否有任何响应?e、 g.到“snmpwalk-v2c-c public localhost”或“snmpwalk-v2c-c public localhost 1.3.6.1.4.1.8072”是的。例如,使用snmpget-v2c-c public localhost sysUpTime.0为我提供了一个有效的响应。我现在不在工作,所以我无法测试它,但查看我在帖子中给出的最后一个snmpget显示,他可以在agnet中找到所有的MIB,直到netSnmpExamples,应该是.8072?现在使用另一台带有旧debian版本的pc,据我所知,突然间,它没有做任何不同的事情就工作了。如何“启动agentx应用程序”,这是做什么的?我以前从未见过这样的指示。
    master  agentx
    
    rocommunity public rwcommunity private
    
    com2sec readonly  default         public 
    com2sec readwrite default     private
    
    snmpd -f -Lo: -Dagentx