Module: Polyseerio::Agent::Handler
- Includes:
- Enum
- Defined in:
- lib/agent/handler/fact.rb,
lib/agent/handler/event.rb,
lib/agent/handler/index.rb,
lib/agent/handler/metric.rb,
lib/agent/handler/process.rb,
lib/agent/handler/interface.rb,
lib/agent/handler/expectation.rb
Overview
Introduce expectation handlers.
Defined Under Namespace
Modules: Interface
Constant Summary collapse
- MAP =
Polyseerio::Helper.dir_proc_map(File.dirname(__FILE__), self)
Class Method Summary collapse
- .event ⇒ Object
- .expectation ⇒ Object
-
.extract_options(options) ⇒ Object
Extracts handler type options from agent options.
- .fact ⇒ Object
- .metric ⇒ Object
- .process ⇒ Object
Class Method Details
.event ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/agent/handler/event.rb', line 9 def self.event { Event::START => proc do |_config, client| client.Event.create( name: "#{client.instance.name} agent has started.", color: Polyseerio::Enum::Color::GREEN, icon: Polyseerio::Enum::Icon::CHAIN ) end, Event::STOP => { Interface::TEARDOWN => proc do |_config, client| client.Event.create( name: "#{client.instance.name} agent has stopped.", color: Polyseerio::Enum::Color::ORANGE, icon: Polyseerio::Enum::Icon::CHAIN_BROKER ) end } } end |
.expectation ⇒ Object
5 6 7 |
# File 'lib/agent/handler/expectation.rb', line 5 def self.expectation {} end |
.extract_options(options) ⇒ Object
Extracts handler type options from agent options.
10 11 12 |
# File 'lib/agent/handler/index.rb', line 10 def self.() .select { |key, _| MAP.key? key } end |
.fact ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/agent/handler/fact.rb', line 5 def self.fact { Fact::ENGINE => proc do |_config, client| client.instance.add_fact('engine', RUBY_ENGINE) end, Fact::GID => proc do |_config, client| client.instance.add_fact('gid', ::Process.gid) end, Fact::LAUNCH_ARGUMENTS => proc do |_config, client| value = ARGV.join('') client.instance.add_fact('launch_arguments', value) end, Fact::PID => proc do |_config, client| client.instance.add_fact('pid', ::Process.pid) end, Fact::PLATFORM => proc do |_config, client| client.instance.add_fact('platform', RUBY_PLATFORM) end, Fact::RUBY_VERSION => proc do |_config, client| client.instance.add_fact('ruby_version', RUBY_VERSION) end, Fact::UID => proc do |_config, client| client.instance.add_fact('uid', ::Process.uid) end } end |
.metric ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/agent/handler/metric.rb', line 5 def self.metric { Metric::MEMORY => proc do |_config, client| client.instance.add_gauge 'memory', 0 end, Metric::CPU => proc do |_config, client| client.instance.add_gauge 'cpu_user', 0 client.instance.add_gauge 'cpu_system', 0 end, Metric::UPTIME => proc do |_config, client| client.instance.add_gauge 'uptime', 0 end } end |
.process ⇒ Object
5 6 7 |
# File 'lib/agent/handler/process.rb', line 5 def self.process {} end |