为什么SNMP的OID给予&QUOT描述;零"? [英] Why the description of the snmp oid giving "null"?
问题描述
我的下code不工作,因为我想使用Net-SNMP库获取一个节点的描述。
My following code is not working as I want to get the description of a node using the Net-Snmp library.
#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)
.........
........
我收到空的所有节点,
I am getting the null for all the nodes,
请告诉我为什么我不能够得到节点的描述,因为它是可用的。当我使用的命令行选项如下
Kindly tell me why I am not able to get the description of nodes as it is available .when I am using the command line option as follow
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
是 OID
的 snmpFrameworkMIB 的code>但你可以看到我在程序的节点之上得到了null作为其
说明
。
1.3.6.1.6.3.10
is the oid
of the snmpFrameworkMIB
but you can see above the node in my program got null as its description
.
任何一个可以知道这里的问题。
Can any one know what is the problem here.
推荐答案
默认情况下,的net-snmp
MIB
解析器不打开描述字符串存储
特别是因为它需要更多的存储器。
By default the net-snmp
MIB
parser does not turn on DESCRIPTION string storage
in particular because it takes more memory.
要打印说明呼叫:
snmp_set_save_descriptions(1);
之前调用 init_snmp()
来强制实施条款的保存。
before calling init_snmp()
to force saving of the DESCRIPTION clauses.
功能无效snmp_set_save_descriptions(INT);
在宣布包括/ NET-SNMP / mib_api.h
和 snmplib / ucd_compat.c
定义。
定义
void
snmp_set_save_descriptions(int save)
{
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
NETSNMP_DS_LIB_SAVE_MIB_DESCRS, save);
}
编辑:
通话 snmp_set_save_descriptions(1);
在 init_snmp()
还.. init_snmp( )
要求 netsnmp_init_mib()
所以不需要调用 netsnmp_init_mib()
如果有一个明确的调用 init_snmp()
call snmp_set_save_descriptions(1);
before init_snmp()
Also ..init_snmp()
calls netsnmp_init_mib()
So not need to call netsnmp_init_mib()
explicitly if one is calling init_snmp()
这篇关于为什么SNMP的OID给予&QUOT描述;零"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!