require "snmp" error in script

  • Thread starter jackster the jackle
  • Start date
J

jackster the jackle

I am trying to require "snmp" in a basic script to poll some networking
devices and I'm getting the following error:

/snmp.rb:4: uninitialized constant SNMP (NameError)
from ./snmp.rb:3:in `require'
from ./snmp.rb:3

I successfully installed the following 3 gems:
snmp (1.0.1)
snmpscan (0.1)
snmptop (0.0.1)

Here is the code in snmp.rb:

#!/usr/local/bin/ruby
require "snmp"
SNMP::Mangager.open:)Host => "172.30.152.1") do |m|
response = m.get(["syslocation.0", "sysuptime.0"])
response.each_varbind { |vb| puts "#{vb.name}: #{vb.value}" }
end

It looks to me like ruby isn't finding the snmp gem that I installed?
Any ideas would be appreciated.

thanks
jackster
 
K

Klodus Klodus

add line

require "rubygems"

at the top

klodus
I am trying to require "snmp" in a basic script to poll some networking
devices and I'm getting the following error:

./snmp.rb:4: uninitialized constant SNMP (NameError)
from ./snmp.rb:3:in `require'
from ./snmp.rb:3

I successfully installed the following 3 gems:
snmp (1.0.1)
snmpscan (0.1)
snmptop (0.0.1)

Here is the code in snmp.rb:

#!/usr/local/bin/ruby
require "snmp"
SNMP::Mangager.open:)Host => "172.30.152.1") do |m|
response = m.get(["syslocation.0", "sysuptime.0"])
response.each_varbind { |vb| puts "#{vb.name}: #{vb.value}" }
end

It looks to me like ruby isn't finding the snmp gem that I installed?
Any ideas would be appreciated.

thanks
jackster
 
J

Joe Martin

I have tried installing and requiring rubygems in my SNMP script...
still getting this error.
 
J

Joe Martin

Duh, it's because I didn't run the setup.rb script in the snmp gem
folder. Fixed now :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top