module Polyseerio::Agent::Handler
Introduce event handlers.
Introduce expectation handlers.
Introduce fact handlers.
Contains handlers and handler map.
Introduce metric handlers.
Introduce process handlers.
Constants
- MAP
Public Class Methods
event()
click to toggle source
# 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()
click to toggle source
# File lib/agent/handler/expectation.rb, line 5 def self.expectation {} end
extract_options(options)
click to toggle source
Extracts handler type options from agent options.
# File lib/agent/handler/index.rb, line 10 def self.extract_options(options) options.select { |key, _| MAP.key? key } end
fact()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/agent/handler/process.rb, line 5 def self.process {} end