From: yermej Date: 2008-01-17T02:00:14+09:00 Subject: Re: Help decoding UDPSocket trap data On Jan 16, 10:23 am, jackster the jackle wrote: > yermej wrote: > > I'm not sure, but the data format is probably dependent on the Cisco > > devices. I would check their documentation for more info. > > > You might also want to check out Ruby SNMP - > >http://snmplib.rubyforge.org/ > > - rather than writing your own socket routines. > > Good call yermej...thanks. > > I copied the basic TrapListener script as follows and am receiving traps > that are readable: > -----------code one --------------- > require 'snmp' > require 'logger' > > log = Logger.new(STDOUT) > m = SNMP::TrapListener.new do |manager| > manager.on_trap_default do |trap| > log.info trap.inspect > puts "------------------" > puts logger.value > end > end > m.join > ---------------------------------- > > Interestingly enough, if I change the code a bit and print out > "logger.value", > you see the exact type of trap formatting that I originally asked about > in my initiail request: > -------------code two ---------------- > log = Logger.new(STDOUT) > m = SNMP::TrapListener.new do |manager| > manager.on_trap_default do |trap| > log.info trap.inspect > puts logger.value > end > end > m.join > ---------------------------------- > What is the best way to get my logger values out if "code one" listed > above so that I can manipulate them? I'd like to be able to access this > output from "code one" for instance: > ----------------------code three ------------ > @value="Interface GigabitEthernet7/12, changed state to down", > --------------------------------------------- > > thanks > > jackster.mobi > -- > Posted viahttp://www.ruby-forum.com/. Sorry, but I'm not seeing much difference between one & two. Where is the local variable logger defined? If "log.info trap.inspect" is printing the type of data you want, I would think that trap.inspect is what you would want to operate on.