Class: Opstat::Plugins::Task

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/opstat-client/plugins.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#log_level, #oplogger, #preconfig_logger

Constructor Details

#initialize(name, queue, config) ⇒ Task



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/opstat-client/plugins.rb', line 25

def initialize (name, queue, config)
  @name = name
  @queue = queue
  @interval = config['interval']
  @interval ||= 60
  @data_sended = {}
  @count_number = 0 #TODO how big it should be
  @send_number = 0 #TODO how big it should be
  @log_level = config['log_level']
  @run = config['run']
  @external_plugin = config['external_plugin']
end

Instance Attribute Details

#intervalObject

, :next_run#, :data, :data_sended



23
24
25
# File 'lib/opstat-client/plugins.rb', line 23

def interval
  @interval
end

#next_runObject

, :next_run#, :data, :data_sended



23
24
25
# File 'lib/opstat-client/plugins.rb', line 23

def next_run
  @next_run
end

Instance Method Details

#external_plugin_needed?Boolean



45
46
47
48
49
50
# File 'lib/opstat-client/plugins.rb', line 45

def external_plugin_needed?
  if @external_plugin.nil?
    return false
  end
  return true
end

#parse_and_queueObject



38
39
40
41
42
43
# File 'lib/opstat-client/plugins.rb', line 38

def parse_and_queue
  oplogger.info "collecting stats"
  report = parse
  oplogger.debug report
  @queue.push({ :timestamp => Time.now, :plugin => @name, :data => report, :interval => @interval})
end