From: Atheeq Pasha Date: 2010-01-19T04:12:20+09:00 Subject: Re: SNMP in rails Miroslaw Niegowski wrote: > 2010/1/18 Atheeq Pasha > >> >> snmpset($row['address']$row['snmp_community_str'],$oid.".".$row['reset_port'],'i','3'); > > > >> >> snmpget($row['address'],$row['snmp_community_str'],$oid.".".$row['reset_port']); >> >> Heh, > Wrong guess :) From php documentation of snmpset/get: > > The "type" parameter must be one of the following, depending on the type > of > variable to set on the SNMP host: > > i INTEGER > u unsigned INTEGER > t TIMETICKS > a IPADDRESS > o OBJID > s STRING > x HEX STRING > d DECIMAL STRING > n NULLOBJ > b BITS > > So I think that the following code should work in ruby: > > require 'snmp' > include SNMP > manager = Manager.new(:Host => host) > varbind = VarBind.new(oid.to_s + "." + row["reset_port"] , > Integer.new(3)) > manager.set(varbind) > > # And get: > .. > response = manager.get(oid.to_s + "." + row["reset_port"]) > > response.each_varbind do |vb| > puts "#{vb.name.to_s} #{vb.value.to_s} > #{vb.value.asn1_type}" > end > > manager.close Thanks a lot. Almost got it working but got an error TypeError: can't convert Fixnum into String at this line varbind = VarBind.new(oid.to_s + "." + result.reset_port , Integer.new(3)) I fixed it by converting reset_port to string i.e., result.reset_port.to_s but it again gave an error NoMethodError: undefined method `new' for Integer:Class for the modified line varbind = VarBind.new(oid.to_s + "." + result.reset_port.to_s , Integer.new(3)) Thanks in advance:) -- Posted via http://www.ruby-forum.com/.