From: Atheeq Pasha Date: 2010-01-21T02:48:01+09:00 Subject: Re: Working with SNMP Kyle Schmitt wrote: >> Darryl > Darryl, isn't driving NetSNMP's cli client from ruby a little > cumbersome? Or are you using the libs directly through ffi? > > For simple snmp stuff I've been using the s2nmp library. > http://members.at.infoseek.co.jp/m6809/ > > It's pretty straight forward, like this little snippet (this just gets > the status of the consumables on a printer). > > #!/usr/bin/ruby > require 'socket' > require 's2nmp' > printer=SNMP.new("lj2") > printer.get("public",["1.3.6.1.2.1.43.11.1.1.9.1.1"]) > puts printer.vars Hello Kyle, It seems simpler and pretty straight forward. I am using this set method to remote reboot APC PDU device via snmp. Can you rewrite this function using s2nmp set method for me oid = '1.3.6.1.4.1.318.1.'; result = GdPortalApcReboot.find_by_device_id(1963) result.address //will have the IP address result.snmp_community_str //will contain community string result.reset_port //contain the reset_port. manager = SNMP::Manager.new(:Host => result.address,:Community => result.snmp_community_str) varbind = VarBind.new(oid.to_s + '.' + result.reset_port.to_s, OctetString.new("3")) manager.set(varbind) manager.close ??????????? and this with s2nmp get method SNMP::Manager.open(:Host => result.address) do |manager| response = manager.get(oid.to_s + "." + result.reset_port.to_s) response.each_varbind do |vb| status = "#{vb.name.to_s} #{vb.value.to_s} #{vb.value.asn1_type}" end end ??????????? When i run these functions I am getting SNMP::RequestTimeout Host xx.xx.xx.xx not responding. Any kind of help will be appreciated. Thanks in advance :) -- Posted via http://www.ruby-forum.com/.