class Threshold::EventFilter

Attributes

comment[RW]
count[RW]
gid[RW]
seconds[RW]
sid[RW]
track_by[RW]
type[RW]

Public Class Methods

new(line="") click to toggle source
# File lib/threshold/event_filter.rb, line 75
def initialize(line="")
  transform(line) unless line.empty?
end

Public Instance Methods

state() click to toggle source
# File lib/threshold/event_filter.rb, line 91
def state
  [@gid, @sid, @type, @track_by, @count, @seconds]
end
to_s(skip = false) click to toggle source
# File lib/threshold/event_filter.rb, line 79
def to_s(skip = false)
  if self.valid?
    if comment?(skip)
      "event_filter gen_id #{@gid}, sig_id #{@sid}, type #{@type}, track by_#{@track_by}, count #{@count}, seconds #{@seconds} #{@comment}"
    else
      "event_filter gen_id #{@gid}, sig_id #{@sid}, type #{@type}, track by_#{@track_by}, count #{@count}, seconds #{@seconds}"
    end
  else
    raise InvalidEventFilterObject, 'Event Filter did not validate'
  end
end

Private Instance Methods

transform(result) click to toggle source
# File lib/threshold/event_filter.rb, line 97
def transform(result)
  begin
    self.gid = result["GID"].compact.first.to_i
    self.sid = result["SID"].compact.first.to_i
    self.type = result["ETYPE"].compact.first
    self.track_by = result["TRACK"].compact.first.split('_')[1]
    self.count = result["COUNT"].compact.first.to_i
    self.seconds = result["SECONDS"].compact.first.to_i
    if result.key?("COMMENT")
      self.comment = result["COMMENT"].compact.first.strip
    end
    raise InvalidEventFilterObject unless self.valid?
  rescue
    raise InvalidEventFilterObject, 'Failed transformation from parser'
  end
end