Class: Bosh::Monitor::Plugins::ConsulEventForwarder
- Includes:
- HttpRequestHelper
- Defined in:
- lib/bosh/monitor/plugins/consul_event_forwarder.rb
Constant Summary collapse
- CONSUL_REQUEST_HEADER =
{ 'Content-Type' => 'application/javascript' }
- TTL_STATUS_MAP =
{ 'running' => :pass, 'failing' => :fail, 'unknown' => :fail, 'default' => :warn }
- REQUIRED_OPTIONS =
["host", "port", "protocol" ]
- CONSUL_MAX_EVENT_BYTESIZE =
512
- CONSUL_ENDPOINTS =
{ event: "/v1/event/fire/", #fire an event register: "/v1/agent/check/register", #register a check deregister: "/v1/agent/check/deregister/", #deregister a check pass: "/v1/agent/check/pass/", #mark a check as passing warn: "/v1/agent/check/warn/", #mark a check as warning fail: "/v1/agent/check/fail/" #mark a check as failing }
Instance Attribute Summary
Attributes inherited from Base
#event_kinds, #logger, #options
Instance Method Summary collapse
Methods included from HttpRequestHelper
#send_http_get_request, #send_http_post_request, #send_http_put_request, #send_http_request
Methods inherited from Base
Constructor Details
This class inherits a constructor from Bosh::Monitor::Plugins::Base
Instance Method Details
#process(event) ⇒ Object
47 48 49 |
# File 'lib/bosh/monitor/plugins/consul_event_forwarder.rb', line 47 def process(event) && forward_event(event) end |
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bosh/monitor/plugins/consul_event_forwarder.rb', line 22 def run @checklist = [] @host = ['host'] @namespace = ['namespace'] @port = ['port'] @protocol = ['protocol'] @params = ['params'] @ttl = ['ttl'] @use_events = ['events'] @ttl_note = ['ttl_note'] @heartbeats_as_alerts = ['heartbeats_as_alerts'] @use_ttl = !@ttl.nil? @status_map = Hash.new(:warn) @status_map.merge!(TTL_STATUS_MAP) logger.info("Consul Event Forwarder plugin is running...") end |
#validate_options ⇒ Object
42 43 44 45 |
# File 'lib/bosh/monitor/plugins/consul_event_forwarder.rb', line 42 def valid_array = REQUIRED_OPTIONS.map{ |o| [o].to_s.empty? } !valid_array.include?(true) end |