couldn't manage cisco switch interface using Ruby snmp

Discussion in 'Ruby' started by Wak Karot, May 2, 2008.

  1. Wak Karot

    Wak Karot Guest

    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 method `encode' 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:in
    `each'
    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:in
    `encode_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:in
    `encode'
    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:in
    `try_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:in
    `try_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
    --
    Posted via http://www.ruby-forum.com/.
    Wak Karot, May 2, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mudcat

    What's the best SNMP interface?

    Mudcat, Oct 11, 2005, in forum: Python
    Replies:
    1
    Views:
    313
    Grig Gheorghiu
    Oct 11, 2005
  2. Replies:
    2
    Views:
    358
  3. Matt Lawrence

    Cisco configuration using Ruby

    Matt Lawrence, Jan 1, 2005, in forum: Ruby
    Replies:
    2
    Views:
    418
    Dave Halliday
    Jan 2, 2005
  4. milaus

    SNMP module to query net-snmp

    milaus, Aug 31, 2006, in forum: Perl Misc
    Replies:
    3
    Views:
    388
    Dr.Ruud
    Aug 31, 2006
  5. Mag
    Replies:
    0
    Views:
    238
Loading...

Share This Page