问题描述
我正在尝试在64位Linux服务器上实现Net-SNMP 5.7.3。目前,我遇到了一个障碍,即无法确定为什么每当getBulkRequest传入OID下方有MIB时,为什么我的Linux服务器都会返回错误代码。当我对相应的OID使用snmpget时,我可以获得每个MIB的信息,但是当我执行snmpbulkget时,我一直在获取
Error in packet.
Reason: (genError) A general failure occured
Failed object: MY-ELEMENT-MIB::myModel.0
我认为我的问题出在我的代理的SNMP配置文件中,但是我无法解决此问题。无论如何,以防万一我错了,我将发布到目前为止已完成的所有工作。希望我的“清理”代码可以使后续操作变得更容易,并在将来帮助其他人。我努力做到这一点。
我的snmp.conf我曾经用来启动代理(位于/ etc / snmp /中)。我正在使用v2c,并向公众开放。
###############################################################################
#
# EXAMPLE.conf:
# An example configuration file for configuring the Net-SNMP agent ('snmpd')
# See the 'snmpd.conf(5)' man page for details
#
# Some entries are deliberately commented out,and will need to be explicitly activated
#
###############################################################################
#
# AGENT BEHAVIoUR
#
# Listen for connections from the local system only
#agentAddress udp:127.0.0.1:161
# Listen for connections on all interfaces (both IPv4 *and* IPv6)
agentAddress udp:161,udp6:[::1]:161
###############################################################################
#
# ACCESS CONTROL
#
####
# First,map the community name (COMmunitY) into a security name
# (local and mynetwork,depending on where the request is coming
# from):
# sec.name source community
com2sec local localhost secret42
com2sec cust1_sec default public
####
# Second,map the security names into group names:
# sec.model sec.name
group MyRWGroup v1 local
group MyRWGroup v2c local
group cust1_grp v1 cust1_sec
group cust1_grp v2c cust1_sec
####
# Third,create a view for us to let the groups have rights to:
# incl/excl subtree mask
view all included .1
#view cust1_v excluded .1
#view cust1_v included sysUpTime.0
#view cust1_v included interfaces.ifTable.ifEntry.ifIndex.1 ff.a0
####
# Finally,grant the groups access to their views:
# context sec.model sec.level match read write notif
access MyRWGroup "" any noauth exact all all none
access cust1_grp "" any noauth exact all all none
# Full read-only access for SNMPv3
#rouser authOnlyUser
# Full write access for encrypted requests
# Remember to activate the 'createuser' lines above
#rwuser authPrivUser priv
###############################################################################
#
# SYstem @R_342_4045@ION
#
# Note that setting these values here,results in the corresponding MIB objects being 'read-only'
# See snmpd.conf(5) for more details
sysLocation Server Room
sysContact Me <[email protected]>
# Application + End-to-End layers
sysServices 72
###############################################################################
#
# ACTIVE MONITORING
#
# send SNMPv1 traps
#trapsink localhost:162 public
# send SNMPv2c traps
#trap2sink localhost public
# send SNMPv2c INFORMs
#informsink localhost public
# Note that you typically only want *one* of these three lines
# Uncommenting two (or all three) will result in multiple copies of each notification.
#
# Event MIB - automatically generate alerts
#
# Remember to activate the 'createuser' lines above
#iquerySecName internalUser
#rouser internalUser
# generate traps on UCD error conditions
#defaultMonitors yes
# generate traps on linkUp/Down
#linkupdownNotifications yes
###############################################################################
#
# EXTENDING THE AGENT
#
#
# AgentX Sub-agents
#
# Run as an AgentX master agent
master agentx
# Listen for network connections (from localhost)
# rather than the default named socket /var/agentx/master
#agentXSocket tcp:localhost:705
启动snmpd(代理)之后,我在C ++应用程序中启动了子代理守护程序。这是我关注的守护程序示例 http://www.net-snmp.org/tutorial/tutorial-5/toolkit/demon/example-demon.c
这是我实现的C ++子代理代码。守护进程调用我的init_myMibSubAgent()而不是init_nstAgentSubagentObject()。
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "myMibSubAgent.h"
#include "SNMPAppData.h"
#include <string>
using namespace std;
void CMyMibSubAgent::init_myMibSubAgent(void)
{
static oid myGeneral_oid[] = { 1,3,6,1,4,1234,2,2};
// myModel; displayString
static oid myModel_oid[] = { 1,1}; // We dont add 0 to end of watch scalar registration oid
netsnmp_register_watched_scalar(
netsnmp_create_handler_registration("myModel",NULL,myModel_oid,OID_LENGTH(myModel_oid),HANDLER_CAN_RWRITE),netsnmp_create_watcher_info(&gSNMPAppData.myGeneral.data.myModel,sizeof(gSNMPAppData.myGeneral.data.myModel),ASN_OCTET_STR,WATCHER_SIZE_STRLEN));
// mySerialCode; displayString
static oid mySerialCode_oid[] = { 1,2}; // We dont add 0 to end of watch scalar registration oid
netsnmp_register_watched_scalar(
netsnmp_create_handler_registration("mySerialCode",mySerialCode_oid,OID_LENGTH(mySerialCode_oid),netsnmp_create_watcher_info(&gSNMPAppData.myGeneral.data.mySerialCode,sizeof(gSNMPAppData.myGeneral.data.mySerialCode),WATCHER_SIZE_STRLEN));
// myType; INTEGER
static oid myType_oid[] = { 1,0};
netsnmp_register_int_instance("myType",myType_oid,OID_LENGTH(myType_oid),&gSNMPAppData.myGeneral.data.myType,NULL );
// mySoftwareRev; displayString
static oid mySoftwareRev_oid[] = { 1,4}; // We dont add 0 to end of watch scalar registration oid
netsnmp_register_watched_scalar(
netsnmp_create_handler_registration("mySoftwareRev",mySoftwareRev_oid,OID_LENGTH(mySoftwareRev_oid),netsnmp_create_watcher_info(&gSNMPAppData.myGeneral.data.mySoftwareRev,sizeof(gSNMPAppData.myGeneral.data.mySoftwareRev),WATCHER_SIZE_STRLEN));
// myState; INTEGER
static oid myState_oid[] = { 1,5,0};
netsnmp_register_int_instance("myState",myState_oid,OID_LENGTH(myState_oid),&gSNMPAppData.myGeneral.data.myState,NULL );
// mySeverityLevel; INTEGER
//static oid mySeverityLevel_oid[] = { 1,0};
//netsnmp_register_int_instance("mySeverityLevel",mySeverityLevel_oid,OID_LENGTH(mySeverityLevel_oid),&gSNMPAppData.myGeneral.data.mySeverityLevel,NULL );
// myAssetTag; displayString
static oid myAssetTag_oid[] = { 1,7}; // We dont add 0 to end of watch scalar registration oid
netsnmp_register_watched_scalar(
netsnmp_create_handler_registration("myAssetTag",myAssetTag_oid,OID_LENGTH(myAssetTag_oid),netsnmp_create_watcher_info(&gSNMPAppData.myGeneral.data.myAssetTag,sizeof(gSNMPAppData.myGeneral.data.myAssetTag),WATCHER_SIZE_STRLEN));
// myTtMaxTargets; Integer32
static oid myTtMaxTargets_oid[] = { 1,0};
netsnmp_register_int_instance("myTtMaxTargets",myTtMaxTargets_oid,OID_LENGTH(myTtMaxTargets_oid),&gSNMPAppData.myTrapTargets.data.myTtMaxTargets,NULL );
// myTtCfgTableNextIndex; Integer32
static oid myTtCfgTableNextIndex_oid[] = { 1,0};
netsnmp_register_int_instance("myTtCfgTableNextIndex",myTtCfgTableNextIndex_oid,OID_LENGTH(myTtCfgTableNextIndex_oid),&gSNMPAppData.myTrapTargets.data.myTtCfgTableNextIndex,NULL );
// myTtCfgTable
for (int i=0; i < vsmNcIpCfgEntry_MAXROWS; i++)
{
// myTtCfgIndex; Integer32
//static oid myTtCfgIndex_oid[] = { 1,i+1};
//string myTtCfgIndexStr = "myTtCfgIndex."+i;
//netsnmp_register_int_instance(myTtCfgIndexStr.c_str(),myTtCfgIndex_oid,OID_LENGTH(myTtCfgIndex_oid),&gSNMPAppData.vsmNcIpCfgEntry.data[i].myTtCfgIndex,NULL );
// myTtCfgIpAddress; IpAddress
oid myTtCfgIpAddress_oid[] = { 1,i+1};
string myTtCfgIpAddressstr = "myTtCfgIpAddress." + std::to_string(i);
netsnmp_register_handler(
netsnmp_create_handler_registration(myTtCfgIpAddressstr.c_str(),handle_myTtCfgIpAddress,myTtCfgIpAddress_oid,OID_LENGTH(myTtCfgIpAddress_oid),HANDLER_CAN_RWRITE));
// myTtCfgCommunity; OCTET STRING
oid myTtCfgCommunity_oid[] = { 1,i+1};
string myTtCfgCommunityStr = "myTtCfgCommunity." + std::to_string(i);
netsnmp_register_watched_instance(
netsnmp_create_handler_registration(myTtCfgCommunityStr.c_str(),myTtCfgCommunity_oid,OID_LENGTH(myTtCfgCommunity_oid),netsnmp_create_watcher_info(&gSNMPAppData.myTtCfgEntry.data[i].myTtCfgCommunity,sizeof(gSNMPAppData.myTtCfgEntry.data[i].myTtCfgCommunity),WATCHER_SIZE_STRLEN));
// myTtCfgEntryStatus; RowStatus
oid myTtCfgEntryStatus_oid[] = { 1,i+1};
string myTtCfgEntryStatusstr = "myTtCfgEntryStatus." + std::to_string(i);
netsnmp_register_int_instance(myTtCfgEntryStatusstr.c_str(),myTtCfgEntryStatus_oid,OID_LENGTH(myTtCfgEntryStatus_oid),&gSNMPAppData.myTtCfgEntry.data[i].myTtCfgEntryStatus,NULL );
}
}
int CMyMibSubAgent::handle_myTtCfgIpAddress(netsnmp_mib_handler *handler,netsnmp_handler_registration *reginfo,netsnmp_agent_request_info *reqinfo,netsnmp_request_info *requests)
{
switch(reqinfo->mode)
{
case MODE_GET:
{
snmp_set_var_typed_value(requests->requestvb,ASN_IPADDRESS,(u_char *)&gSNMPAppData.vsmNcIpCfgEntry.data[1].vsmIpAddress,sizeof(gSNMPAppData.vsmNcIpCfgEntry.data[1].vsmIpAddress));
}
break;
case MODE_SET_RESERVE1:
break;
case MODE_SET_RESERVE2:
break;
case MODE_SET_FREE:
break;
case MODE_SET_ACTION:
break;
case MODE_SET_COMMIT:
break;
case MODE_SET_UNDO:
break;
default:
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
最后,这是我放置在Manager / usr / share / snmp / mibs /目录中的MIB模块,该模块调用snmpbulkget和snmpget
--
-- Common Object DeFinitions for My Element MIB
--
MY-ELEMENT-MIB DEFinitioNS ::= BEGIN
-- Relationship to Other MIBs
--
--
-- The objects defined in this MIB are located under the
-- private.enterprises subtree as shown below:
--
-- iso(1).org(3).dod(6).internet(1)
-- |
-- private(4)
-- |
-- enterprises(1)
-- |
-- myOID(1234)
-- |
-- myRegistrations(2)
-- |
-- myElementMIB(1)
--
--
--
-- Object Synopsis
--
--
-- All objects within this MIB are prefixed with the OBJECT
-- IDENTIFIER "p",where "p" is:
--
-- iso(1).org(3).dod(6).internet(1).private(4).enterprises(1).
-- myOID(1234).myRegistrations(2).myElementMIB(1)
--
-- or,1.3.6.1.4.1.1234.2.1
--
--
-- Object Name Object Id
-- ================================ ==============
--
-- myMIBNotifications p.0
-- myStateChange p.0.1
-- myGeneral p.2
-- myModel p.2.1.0
-- mySerialCode p.2.2.0
-- myType p.2.3.0
-- mySoftwareRev p.2.4.0
-- myState p.2.5.0
-- mySeverityLevel p.2.6.0
-- myAssetTag p.2.7.0
-- myTrapTargets p.3
-- myTtMaxTargets p.3.1.0
-- myTtCfgTableNextIndex p.3.2.0
-- myTtCfgTable p.3.3
-- myTtCfgEntry p.3.3.1
-- myTtCfgIndex p.3.3.1.1.n
-- myTtCfgIpAddress p.3.3.1.2.n
-- myTtCfgCommunity p.3.3.1.3.n
-- myTtCfgEntryStatus p.3.3.1.4.n
--
IMPORTS
MODULE-IDENTITY,NOTIFICATION-TYPE,object-type,IpAddress,TimeTicks,Integer32
FROM SNMPv2-SMI
TEXTUAL-CONVENTION,displayString,RowStatus
FROM SNMPv2-TC
myRegistrations
FROM MY-REG;
myElementMIB MODULE-IDENTITY
LAST-UPDATED "200503230000Z"
ORGANIZATION "My Solutions,Inc."
CONTACT-INFO
"
My Solutions,Inc.
123 Smith Ave
Los Angeles,CA 12345,USA.
phone: +1 (123) 123-4567
e-mail: [email protected]
http://www.website.com/support"
DESCRIPTION
"This MIB module describes the generic
characteristics of a manageable physical
element beneath the my enterprise."
REVISION "9911120000Z"
DESCRIPTION
"First draft."
REVISION "200004100000Z"
::= { myRegistrations 1 }
--
-- Element MIB Textual Conventions
--
MyFloatingPoint ::= TEXTUAL-CONVENTION
disPLAY-HINT
"63a"
STATUS current
DESCRIPTION
"FloatingPoint provides a way of representing
non-integer numbers in SNMP. Numbers are
represented as a string of ASCII characters in
the natural way. So for example,'3','3.142'
and '0.3142E1' are all valid numbers.
The Syntax for the string is as follows. []
enclose an optional element,| is the separator
for a set of alternatives. () enclose Syntax
which is to be viewed as a unit.
FloatingPoint ::= [Sign]
(Float1 | Float2 | DigitSequence)
[ExponentPart]
Float1 ::= DigitSequence '.' [DigitSequence]
Float2 ::= '.' DigitSequence
DigitSequence ::= Digit [DigitSequence]
ExponentPart ::= ('e' | 'E') [Sign] DigitSequence
Digit ::= '0'..'9'
Sign ::= '+' | '-'"
Syntax OCTET STRING (SIZE (1..63))
MyTimecode ::= TEXTUAL-CONVENTION
disPLAY-HINT
"11a"
STATUS current
DESCRIPTION
"A display representation for timecode which
essentially provides a machine readable address
for video and audio. Timecodes are represented as
a string of ASCII characters as hh:mm:ss:ff where
hh is hours,mm is minutes,ss is seconds and
ff is video frames."
Syntax OCTET STRING (SIZE (0..11))
--
-- The Element MIB top-level groups
--
-- NOTE: { myElementMIB 1 } is reserved for internal use
myGeneral OBJECT IDENTIFIER ::= { myElementMIB 2 }
myTrapTargets OBJECT IDENTIFIER ::= { myElementMIB 3 }
--
-- The Element MIB Object DeFinitions
--
--
-- The General Group
-- The myGeneral group provides general
-- @R_342_4045@ion for the my managed element.
--
myModel object-type
Syntax displayString (SIZE(0..64))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The element model string. The preferred value is
the customer-visible part number,which may be
printed on the physical managed element itself.
If the element being managed does not have
a model descriptor,or the model descriptor is
unkNown to the agent,the value of this variable
will be a null string."
::= { myGeneral 1 }
mySerialCode object-type
Syntax displayString (SIZE(0..64))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The manufacturing serial code of the
element on which the management software
is running. The preferred value is the serial
number string actually printed on the CCU itself
(if present).
If the element being managed does not have
a serial code,the value of this variable
will be a null string."
::= { myGeneral 2 }
myType object-type
Syntax INTEGER {
myTypeUnkNown(1),-- My Type
myType1(2),-- My Type
myType2(3),-- My Type
myType3(4)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Identifies the type of the element being managed."
::= { myGeneral 3 }
mySoftwareRev object-type
Syntax displayString (SIZE(0..64))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The revision stamp of the software running on
the element that supports this MIB module."
::= { myGeneral 4 }
myState object-type
Syntax INTEGER {
myElementRunning(1),myElementInMaintenance(2),myElementFaulty(3),myElementdisabled(4),myElementIdling(5),myElemen@R_404_6193@tializing(6),myElementResetting(7),myElementHalted(8),myElementSwLicenseExpired(9),myElementImntSwLicExpiry(10),myElementSwLicRecovered(11)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The operational state of an element."
::= { myGeneral 5 }
mySeverityLevel object-type
Syntax INTEGER {
levelUnkNown(1),levelTrace(2),level@R_342_4045@ional(3),levelnormal(4),levelWarning(5),levelAlarm(6),levelResentWarning(7),levelResentAlarm(8)
}
MAX-ACCESS accessible-for-notify
STATUS current
DESCRIPTION
"Defines the typical severity levels"
::= { myGeneral 6 }
myAssetTag object-type
Syntax displayString (SIZE(0..64))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"This object is a user-assigned asset tracking identifier for
the element"
::= { myGeneral 7 }
--
-- The Trap Targets Group
-- The myTrapTargets group provides means to
-- configure the trap target specifics using which an
-- element can dispatch traps.
--
myTtMaxTargets object-type
Syntax Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The maximum number of trap targets that this
element can support.
If the value of this variable is -1,the element
element is capable of supporting a theoretically
infinite number of trap targets dynamically. In
othercases,the maximum number of trap targets
that can be supported by this element is limited
to the value of this variable."
::= { myTrapTargets 1 }
myTtCfgTableNextIndex object-type
Syntax Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Identifies a hint for the next value of
myTtCfgIndex to be used in a row creation attempt
for the myTtCfgTable table. If no new rows can be
created,this object will have a value of 0."
::= { myTrapTargets 2 }
myTtCfgTable object-type
Syntax SEQUENCE OF MyTtCfgEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"A list of trap target configuration entries on
this element.
Trap Target Configuration Entry Creation:
=========================================
When creating a trap target configuration entry
the manager should use a GET operation to
determine the value of myTtCfgTableNextIndex.0.
If this value is non-zero,the manager can then
use this value as the index while creating a
table row.
The process of creating and activating a row of
this table takes two forms: the one-set mode and
the multiple-set mode.
In the one-set mode,a manager must specify the
values of myTtCfgIpAddress and myTtCfgCommunity
required to activate a row in a single SET operation
along with an assignment of the myTtCfgEntryStatus
to 'createAndGo(4)'. If the values and instances
supplied are correct,an instance of the trap target
configuration is created and the value of
myTtCfgEntryStatus transitions to 'active(1)'.
for example:
============
SnmpGet(<myTtCfgTableNextIndex.0,NULL>)
returns
<myTtCfgTableNextIndex.0,2>
SnmpSet(<myTtCfgIpAddress.2,192.158.104.93>,<myTtCfgCommunity.2,'public'>,<myTtCfgEntryStatus.2,createAndGo(4)>)
returns
<myTtCfgIpAddress.2,active(1)>
In the multiple-set mode,creating a trap target
configuration table row,filling it with values,and activating it are carried out in discrete steps.
To create the row,the manager specifies a value
of 'createAndWait(5)' for the myTtCfgEntryStatus
status variable. This SET request Could contain
values of myTtCfgIpAddress and myTtCfgCommunity
but it is not required. More often,the values for
these columnar objects are specified in additional
SET requests. After each SET operation,the
myTtCfgEntryStatus variable takes on the value
'notReady(3)' or 'notinService(2)'. To place the
entry into service,the manager requests that the
myTtCfgEntryStatus variable transition to the
'active(1)' state.
for example:
============
SnmpGet(<myTtCfgTableNextIndex.0>,NULL)
returns
<myTtCfgTableNextIndex.0,2>
SnmpSet(<myTtCfgEntryStatus.2,createAndWait(5)>)
returns
<myTtCfgEntryStatus.2,notReady(3)>
SnmpSet(<myTtCfgIpAddress.2,'public'>)
returns
<myTtCfgIpAddress.2,'public'>
SnmpSet(<myTtCfgEntryStatus.2,active(1)>)
returns
<myTtCfgEntryStatus.2,active(1)>
Trap Target Configuration Entry Deletion:
=========================================
To delete an existing trap target configuration
entry,the manager performs a SET operation on the
myTtCfgEntryStatus variable with the value
'destroy(6)'."
::= { myTrapTargets 3 }
myTtCfgEntry object-type
Syntax MyTtCfgEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"A trap target configuration entry."
INDEX { myTtCfgIndex }
::= { myTtCfgTable 1 }
MyTtCfgEntry ::=
SEQUENCE {
myTtCfgIndex
Integer32,myTtCfgIpAddress
IpAddress,myTtCfgCommunity
OCTET STRING,myTtCfgEntryStatus
RowStatus
}
myTtCfgIndex object-type
Syntax Integer32 (1..2147483647)
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
"The index of a trap target configuration row.
Note that the value of this object will not
be visible to a manager and any GET/SET
operations on this variable will fail."
::= { myTtCfgEntry 1 }
myTtCfgIpAddress object-type
Syntax IpAddress
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The IP address of the target/manager to which
this element is supposed to send notifications."
::= { myTtCfgEntry 2 }
myTtCfgCommunity object-type
Syntax OCTET STRING (SIZE(0..128))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The community name to be used when this element
sends notifications to the target identified by
this value of this entries myTtCfgIpAddress."
::= { myTtCfgEntry 3 }
myTtCfgEntryStatus object-type
Syntax RowStatus
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"This object controls the creation,activation
and deletion of a row in trap target configuration
table."
::= { myTtCfgEntry 4 }
--
-- The Element MIB Notifications
--
--
-- The notifications group is being assigned the OID "0" so as
-- to comply with the trap handling in the different SNMP versions
--
myMIBNotifications OBJECT IDENTIFIER ::= { myElementMIB 0 }
myStateChange NOTIFICATION-TYPE
OBJECTS {
myState
}
STATUS current
DESCRIPTION
"Notifies when a state change occurs on an element.
The myState variable will hold the new state that
the element is operating in."
::= { myMIBNotifications 1 }
END
我在Manager上使用的snmpget命令
snmpget -v 2c -c public 10.16.20.191 MY-ELEMENT-MIB::myModel.0
MY-ELEMENT-MIB::myModel.0 = STRING: Hello World
我在Manager上使用的snmpbulkget命令
snmpbulkget -v 2c -c public 10.16.20.191 MY-ELEMENT-MIB::myGeneral
Error in packet.
Reason: (genError) A general failure occured
Failed object: MY-ELEMENT-MIB::myModel.0
附加说明:
- 直接使用OID可获得相同的结果
- 使用Wireshark,我看到我的Linux系统对getBulkRequest的响应以及在OID下找到的所有MIB信息
- 我在snmpbulkget命令中使用了-DALL开关,我看到在OID下找到的所有MIB信息。此外,我看到错误状态= 5,这说明了为什么我得到genError response。
解决方法
我发现了我的问题。我的问题是我用来注册 myTtCfgIpAddress OID 的 Netsnmp_Node_Handler 方法。我在 CMyMibSubAgent::handle_myTtCfgIpAddress() 中缺少 MODE_GETNEXT 和 MODE_GETBULK 案例。因此,我的 switch case 默认返回 SNMP_ERR_GENERR。
现在我向遇到此问题的任何人建议,不要仅仅依赖 SNMP 工具响应。 snmpbulkget -DALL 命令告诉我问题出在我的第一个 OID 对象(在我的例子中是 MY-ELEMENT-MIB::myModel.0)。然而,在使用 Wireshark 之后,我发现前几个 OID 返回了有效值,但是在它到达我的 myTtCfgTable 之后,它开始出现问题。从这里开始,我开始使用 snmpgetnext 和 Wireshark 来查明导致 genError 的特定 OID。在那之后,它只是对 OID 实现的审查(在我的情况下,我不得不使用调试器来确定我得到的 reqinfo->mode 是 MODE_GETNEXT)。希望这个解释对未来的人有所帮助。
还有一件事,我使用 Wireshark 过滤器“udp.port==161 || udp.port==162”来仅观察 SNMP 流量。