Class: Nagios::BackgroundParser

Inherits:
Object
  • Object
show all
Defined in:
lib/nagira/background_parse.rb

Overview

Background parsing of status.dat file in separate thread. Runs on regular intervals slightly shorter than :ttl

Instance Method Summary (collapse)

Constructor Details

- (BackgroundParser) initialize

If :ttl is not defined set to 0 and do not run background parsing.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/nagira/background_parse.rb', line 15

def initialize
  interval = [::DEFAULT[:ttl],1].max || nil
  $use_inflight_status = false
  $use_inflight_objects = false
  if interval && ::DEFAULT[:start_background_parser]
    puts "[#{Time.now}] Starting background parser thread with interval #{interval} sec"
    $bg = Thread.new {
      loop {
        $use_inflight_status ? $nagios[:status].parse : $nagios[:status_inflight].parse
        $use_inflight_status = !$use_inflight_status
        sleep interval
      } #loop
    } # thread
  end
end