Class: Bipbip::Plugin::LogParser
- Inherits:
-
Bipbip::Plugin
- Object
- Bipbip::Plugin
- Bipbip::Plugin::LogParser
- Defined in:
- lib/bipbip/plugin/log_parser.rb
Instance Attribute Summary
Attributes inherited from Bipbip::Plugin
#config, #metric_group, #name, #pid
Instance Method Summary collapse
Methods inherited from Bipbip::Plugin
factory, #frequency, #initialize, #interrupt, #interrupted?, #metrics_names, #run, #source_identifier
Methods included from InterruptibleSleep
#interrupt_sleep, #interruptible_sleep
Constructor Details
This class inherits a constructor from Bipbip::Plugin
Instance Method Details
#metrics_schema ⇒ Object
7 8 9 10 11 |
# File 'lib/bipbip/plugin/log_parser.rb', line 7 def metrics_schema config['matchers'].map do |matcher| {:name => matcher['name'], :type => 'gauge', :unit => 'Boolean'} end end |
#monitor ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bipbip/plugin/log_parser.rb', line 13 def monitor unless IO.select([notifier.to_io], [], [], 0).nil? n = notifier begin n.process rescue NoMethodError => e # Ignore errors from closed notifier - see https://github.com/nex3/rb-inotify/issues/41 raise e unless n.watchers.empty? end end lines = @lines.entries @lines.clear Hash[ config['matchers'].map do |matcher| name = matcher['name'] regexp = Regexp.new(matcher['regexp']) value = lines.reject { |line| line.match(regexp).nil? }.length [name, value] end ] end |