Forum: Ruby snmp with s2nmp or rubyonrails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E3e1f180336c0704be73a5335df4e8d0?d=identicon&s=25 hemtirik (Guest)
on 2005-12-07 08:12
(Received via mailing list)
Hi all,

 I'm using Ruby about 3-4 mounts. Now, i want to make a project about
network devices with SNMP.

 But, until this time; i haven't used rubyonrails yet.

 Yesterday (i hope) i've installed rubyonrails. And i made some steps
like that:

 # rails /home/student/new_directory

 and i copy a script in it like:

 ------------------------------

 #!/usr/bin/ruby
 require 'snmp'

 ifTable_columns =
     ["ifIndex", "ifDescr", "ifInOctets", "ifOutOctets"]
     SNMP::Manager.open(:Host => 'localhost') do |manager|
       manager.walk(ifTable_columns) do |row|
           row.each { |vb| print "\t#{vb.value}" }
               puts
                 end
                 end

 -----------------------------


 But it tells me;
 `require': no such file to load -- snmp (LoadError)

 I tried to fix this but i couldn't do anything.

 So i gave up to do it with rubyonrails; and installed s2nmp
(http://members.at.infoseek.co.jp/m6809/ex_get.html).

 This time; i tried to run this script like: #ruby example.rb 10.0.0.2
 (i couldn't find an ip address to make excercises so i tried to use my
adsl router: 10.0.0.2)


 ------------------------------
 # Usage: ruby getsysdsc.rb
 #
 #
 require 'socket'
 require 's2nmp'

 host=ARGV.shift

 s=SNMP.new(host)
 sts=s.get("public",["1.3.6.1.2.1.1.1.0"])
 if sts then
   p s.vars
   else
     print "TIMEOUT."
     end


 ------------------------------


 It tells me:
 -------------------
 /usr/lib/ruby/1.8/s2nmp.rb:267:in `recv': Connection refused -
recvfrom(2) (Errno::ECONNREFUSED)
         from /usr/lib/ruby/1.8/s2nmp.rb:267:in `get'
         from example.rb:10
 ----------------------


 Can you give me any ideas or advices? Plus; i haven't decide to make it
with s2nmp or rubyonrails.

 Best Regards,

 Esravan Rolda.
This topic is locked and can not be replied to.