Forum: Ruby ruby-snmp annoying problem :(

A6bf3348cbf9f24149c1b6d57cc9b9c9?d=identicon&s=25 mj-usunto (Guest)
on 2005-11-18 16:55
(Received via mailing list)
Simple script (Should set Integer=1 into device)

#!/usr/local/bin/ruby
require 'rubygems'
require 'snmp'
include SNMP

manager = Manager.new(:Host => '10.20.9.53')
varbind = VarBind.new("1.3.6.1.2.1.69.1.1.3.0", Integer(1))
manager.set(varbind)
manager.close

Result:
warbird soaftp # ./lo.rb
[cut crap]
/usr/local/lib/ruby/gems/1.8/gems/snmp-0.5.1/lib/snmp/manager.rb:264:in
`set': host 10.20.9.53 not responding (SNMP::RequestTimeout)
        from ./lo.rb:8

This looks like lie to me :
warbird soaftp # ping 10.20.9.53
10.20.9.53 is alive
warbird soaftp #
Using snmpset from net-snmp package I'm able to set this value..

Get is OK but I'm not able to create working version of set :(

Help please :)
22b74ae3adfc74ff5c7c0b0a94b78a48?d=identicon&s=25 kozlov.y (Guest)
on 2005-11-21 11:21
(Received via mailing list)
>manager.close
>
>Result:
>warbird soaftp # ./lo.rb
>[cut crap]
>/usr/local/lib/ruby/gems/1.8/gems/snmp-0.5.1/lib/snmp/manager.rb:264:in
>`set': host 10.20.9.53 not responding (SNMP::RequestTimeout)
>        from ./lo.rb:8

Try this:
manager = SNMP::Manager.new(:Host => '10.20.9.53', :Version => :SNMPv1,
:Community => !!you community here!!)
62ad59948dc76c7215de8fd9a2021af3?d=identicon&s=25 Chandra Sekhar (chandrasekhar29)
on 2013-03-19 13:58
Tried to set a an Integer data type as defined above. However, SET not
sucess and getting error as

C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/varbind.rb:599:in
`encode': undefined method `encode' for 1:Fixnum (NoMethodError)
  from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/varbind.rb:54:in
`block in encode'
  from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/varbind.rb:53:in
`each'
  from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/varbind.rb:53:in
`encode'
  from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/pdu.rb:181:in
`encode_pdu'
  from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/pdu.rb:204:in
`encode'
  from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/pdu.rb:110:in
`encode'
  from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/manager.rb:506:in
`send_request'
  from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/manager.rb:490:in
`block in try_request'
  from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/manager.rb:489:in
`times'
  from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/manager.rb:489:in
`try_request'
  from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/manager.rb:293:in
`set'
  from test2.rb:28:in `<main>'

Can anybody help me what is the issue?

Thanks in advance
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2013-03-19 14:11
Looks like line 28 is passing a number somewhere rather than a string.
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 tamouse mailing lists (Guest)
on 2013-03-21 02:43
(Received via mailing list)
On Tue, Mar 19, 2013 at 7:58 AM, Chandra Sekhar <lists@ruby-forum.com>
wrote:
> Tried to set a an Integer data type as defined above. However, SET not
> sucess and getting error as

As this is a mailing list, I have no idea what "above" is.

> C:/Ruby192/lib/ruby/gems/1.9.1/gems/snmp-1.1.0/lib/snmp/varbind.rb:599:in
> `encode': undefined method `encode' for 1:Fixnum (NoMethodError)

Pay attention to the above error. It says that what you are applying
the method `encode` to is a Fixnum, a number.

All the rest of the stacktrace is probably unnecessary to post.
0df84f767bfabf67d593d02d72c80aa4?d=identicon&s=25 Jeff Wolak (wershlak)
on 2013-03-22 19:20
mj-usunto wrote in post #2768:

> varbind = VarBind.new("1.3.6.1.2.1.69.1.1.3.0", Integer(1))
> manager.set(varbind)
> manager.close
> Help please :)

try:

varbind = VarBind.new("1.3.6.1.2.1.69.1.1.3.0", Integer.new(1))
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.