0
我的下面的代码不工作,因为我想使用Net-Snmp库来获取节点的描述。为什么描述snmp oid给出“null”?
#include "net-snmp/net-snmp-config.h"
#include "net-snmp/net-snmp-includes.h"
void print_s(struct tree *);
int main(int argc, char ** argv)
{
char buff[100];
struct tree *node=NULL;
init_mib();
node=read_all_mibs();
if(node == NULL)
{
exit(2);
}
print_s(node);
}
void print_s(struct tree *tree)
{
struct tree *tp;
for (tp = tree->child_list; tp; tp = tp->next_peer)
{
printf("%s:%s\n",tp->label,tp->description);
}
for (tp = tree->child_list; tp; tp = tp->next_peer)
{
if (tp->child_list)
print_s(tp);
}
}
o/p-
org:(null)
dod:(null)
internet:(null)
snmpV2:(null)
security:(null)
private:(null)
experimental:(null)
mgmt:(null)
directory:(null)
snmpModules:(null)
snmpProxys:(null)
snmpDomains:(null)
snmpMIB:(null)
snmpFrameworkMIB:(null)
.........
........
我正在为所有节点空,
请告诉我为什么我不能够得到节点的描述,因为它是可用的。当我使用的命令行选项如下
snmptranslate -On -Td 1.3.6.1.6.3.10
Result
-----------
.1.3.6.1.6.3.10
snmpFrameworkMIB MODULE-IDENTITY
-- FROM SNMP-FRAMEWORK-MIB
DESCRIPTION "The SNMP Management Architecture MIB
Copyright (C) The Internet Society (2002). This
version of this MIB module is part of RFC 3411;
see the RFC itself for full legal notices.
"
::= { iso(1) org(3) dod(6) internet(1) snmpV2(6) snmpModules(3) 10 }
1.3.6.1.6.3.10
是snmpFrameworkMIB
的oid
但你可以看到上面的节点在我的程序作为其description
了空。
任何人都可以知道这里有什么问题。
谢谢,Grijesh需要调用
netsnmp_init_mib()
明确,为答案。 – pradipta