2011-12-27 47 views
1

我想讓net-snmp支持我自己的MIB,但是我失敗了。我按照這裏的說明: http://www.net-snmp.org/wiki/index.php/TUT:Writing_a_MIB_Modulenet-snmp tutorial snmpset failed

然後,我想也許我可以使用示例MIB文件和.c和.h文件來測試示例是否工作。同樣,在上面的鏈接下面的教程,我得到這個工作:

snmpget -v2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 

,我得到這個:

NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 = INTEGER: 1(這看起來很不錯)。

但後來我嘗試測試snmpset這樣的:

snmpset -v 2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 i 5

snmpset -v 2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 = 5 

snmpset -v 2c -c public localhost NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 INTEGER 5 

,我得到了以下錯誤:

Error in packet. 
Reason: wrongLength (The set value has an illegal length from what the agent expects) 
Failed object: NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 

請幫我理解我在哪裏做錯了。所有的文件都來自教程,我沒有 改變任何東西。

在此先感謝!

回答

2

如果您是在64位目標編程this可以幫助你

+0

是的,這是因爲我在一臺64位機器上運行它。在我切換到32位機器後,我可以設置並且沒有任何問題。 – user195678 2012-03-26 22:39:52

0

如果您想保留64位機器上運行,你可以變量從int長改變:

static int nstAgentModuleObject = 1; ==>static long ..... netsnmp_register_int_instance(....) ==>netsnmp_register_long_instance(....)