2

I am trying to make net-snmp to support my own MIB, but I failed. I was following the instructions here: http://www.net-snmp.org/wiki/index.php/TUT:Writing_a_MIB_Module.

Then I think maybe I could just use the example MIB file and .c and .h file to test if the example works. Again, by following the tutorials in the above link, I get this to work:

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

and I got this:

NET-SNMP-TUTORIAL-MIB::nstAgentModuleObject.0 = INTEGER: 1 (which looks good).

But then I try to test snmpset like this:

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

or

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

or

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

and I got the following error:

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

Please help me understand where did I do wrong. All the files are from the tutorial and I did not change anything.

Thanks in advance!

JPBlanc
  • 70,406
  • 17
  • 130
  • 175
user195678
  • 535
  • 4
  • 13
  • 27

2 Answers2

2

If you are programming on a 64bit target this can help you

JPBlanc
  • 70,406
  • 17
  • 130
  • 175
  • Yes, this is because of I was running it on a 64bit machine. After I switch to a 32bit machine, I can set and get without any problems. – user195678 Mar 26 '12 at 22:39
0

If you want to keep running on a 64bit machine you can change the variable from int to long:

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

barsju
  • 4,408
  • 1
  • 19
  • 24