Couldn't manage cisco switch interface using Ruby snmp

Hi guy,

I’m just created script to shutdown and bring up cisco switch interface

#!/usr/bin/env ruby
require ‘rubygems’
require ‘snmp’
include SNMP

manager = Manager.new(:Host => ‘10.111.1.30’, :WriteCommunity=>
‘write’, :Version => :SNMPv2c)
varbind = VarBind.new(“1.3.6.1.2.1.2.2.1.7.19”, Integer(2))
manager.set(varbind)
manager.close

but i got this error

/usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/varbind.rb:562:in
encode': undefined methodencode’ for 2:Fixnum (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/varbind.rb:48:in
encode' from /usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/varbind.rb:47:ineach’
from /usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/varbind.rb:47:in
encode' from /usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/pdu.rb:181:inencode_pdu’
from /usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/pdu.rb:204:in
encode' from /usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/pdu.rb:110:inencode’
from /usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/manager.rb:478:in
send_request' from /usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/manager.rb:462:intry_request’
from /usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/manager.rb:461:in
times' from /usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/manager.rb:461:intry_request’
from /usr/lib/ruby/gems/1.8/gems/snmp-1.0.1/lib/snmp/manager.rb:266:in
`set’
from setsnmp.rb:8

if i using snmpset it worked perfectly, any help

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs