class MtrHost
Attributes
addr[RW]
dns[RW]
hostid[RW]
pings[RW]
recs[RW]
totalreplies[RW]
Public Class Methods
new(rec,pingcount,recs)
click to toggle source
# File lib/logstash/codecs/mtrraw.rb, line 21 def initialize(rec,pingcount,recs) @hostid = rec.id @addr = rec.data @recs = recs @pings = recs.select{|each| each.type == 'p'}.collect {|each|each.data} @pingloss = (100.to_f - (100.to_f * (@pings.size.to_f / pingcount.to_f))).to_i if pingcount.to_i > 0 @avgrtt = (@pings.inject(0.0) {|counter,each| counter += (each.to_f/1000)} / @pings.size).to_i @dns = recs.select{|each| each.type =='d'}.collect {|each|each.data}.pop end
Public Instance Methods
to_event_struct()
click to toggle source
# File lib/logstash/codecs/mtrraw.rb, line 30 def to_event_struct {:hostid => @hostid, :addr => @addr , :pings => @pings ,:dns => @dns,:pingloss => @pingloss,:avgrtt => @avgrtt} end