From: Jason Ballou Date: 2008-01-23T11:48:14+09:00 Subject: ActiveRecord help Im a ruby newb trying to learn how pull snmp data from devices and put into database. I am testing with two paticular snmp entities: ifindex and ifdescr and put the values from the poll into thier respective colums/rows in a mysql db called test in the interfaces table. I tried the unDRY conventions :P by duplicating my polls and putting them into thier respective rows however I didnt get what i wanted. Being a super newb, I am unable to figure out conceptually how to accomplish this. Any assitance would be greatly appreciated. DB output the outcome i get is: id interfaces | 1 | NULL | | 2 | NULL | | 3 | NULL | | 0 | Ethernet0/0 | | 0 | Serial0/0 | | 0 | Ethernet0/1 | the outcome i would love to have is: id interfaces | 1 | Ethernet0/0 | | 2 | Serial0/0 | | 3 | Ethernet0/1 | My code require 'rubygems' require 'snmp' require 'mysql' require 'active_record' ActiveRecord::Base.establish_connection( :adapter => "mysql", :host => "localhost", :database => "test" ) class Server < ActiveRecord::Base set_table_name "interfaces" end ifTable_columns = ["ifIndex", ] SNMP::Manager.open(:Host => '10.0.0.1', :Version => :SNMPv2c, :Community => 'pub') do |manager| manager.walk(ifTable_columns) do |row| row.each { |vb| print "\t#{vb.value}" server = Server.new server.id = "#{vb.value}" server.save } end end ifTable_columns = ["ifDescr", ] SNMP::Manager.open(:Host => '10.0.0.1', :Version => :SNMPv2c, :Community => 'pub') do |manager| manager.walk(ifTable_columns) do |row| row.each { |vb| print "\t#{vb.value}" server = Server.new server.interfaces = "#{vb.value}" server.save } end end -- Posted via http://www.ruby-forum.com/.