Class: Nucleon::Plugin::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/core/plugin/agent.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.describe_base(group = nil, action = 'unknown', weight = -1000,, description = nil, help = nil, provider_override = nil) ⇒ Object


Info



13
14
15
16
17
# File 'lib/core/plugin/agent.rb', line 13

def self.describe_base(group = nil, action = 'unknown', weight = -1000, description = nil, help = nil, provider_override = nil)
  group = array(group).collect! {|item| item.to_sym }
  group = [ :agent ] | group
  super(group.uniq, action, weight, description, help, provider_override)
end

Instance Method Details

#agent_configObject




49
50
51
52
53
54
# File 'lib/core/plugin/agent.rb', line 49

def agent_config
  register_bool :log, true, 'corl.core.action.agent.options.log'
  register_bool :truncate_log, true, 'corl.core.action.agent.options.truncate_log'

  register_str :log_file, "/var/log/corl/#{plugin_provider}.log", 'corl.core.action.agent.options.log_file'
end

#argumentsObject




31
32
33
34
35
36
37
38
# File 'lib/core/plugin/agent.rb', line 31

def arguments
  # Don't use or the default log file naming will screw up due to having to
  # move daemonization to the corl loader.
  #
  # See: lib/corl.rb
  #
  []
end

#configureObject


Property accessor / modifiers



22
23
24
25
26
27
# File 'lib/core/plugin/agent.rb', line 22

def configure
  super do
    yield if block_given?
    agent_config
  end
end

#execute(use_network = true, &block) ⇒ Object


Operations



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/core/plugin/agent.rb', line 59

def execute(use_network = true, &block)
  super do |node|
    ensure_network do
      trap(:INT) do
        safe_exit
      end

      add_agent(node)
      block.call(node)
      remove_agent(node) if myself.status == code.success
    end
  end
end

#pidObject


Settings



43
44
45
# File 'lib/core/plugin/agent.rb', line 43

def pid
  settings[:pid]
end