Class: FWC::Raw
- Inherits:
-
Object
- Object
- FWC::Raw
- Defined in:
- lib/fwc.rb
Instance Method Summary collapse
-
#initialize(matcher, opts = {}) ⇒ Raw
constructor
A new instance of Raw.
- #receive(data) ⇒ Object
- #report! ⇒ Object
Constructor Details
#initialize(matcher, opts = {}) ⇒ Raw
Returns a new instance of Raw.
152 153 154 155 156 157 158 159 |
# File 'lib/fwc.rb', line 152 def initialize matcher, opts={} @threshold = opts[:threshold] @matcher = matcher @count = 0 @rate = 0 @disabled = false @first = Time.now end |
Instance Method Details
#receive(data) ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/fwc.rb', line 172 def receive data return if not @matcher.matches? data if not @tags.nil? and not (@tags & (d["tags"] || [])).empty? return end if not @disabled and @count > 100 diff = (Time.now - @first) rate = (@count / diff) if rate > @threshold r = rate.to_i desc = "#{r}/s > #{@threshold}/s" FWC.log.info "Raw: disabled - rate too high (#{desc})" @disabled = true end end unless @disabled FWC.log.info "#{@count}: #{data}" end @count += 1 end |