Class: Bosh::Monitor::Plugins::Pagerduty
- Includes:
- HttpRequestHelper
- Defined in:
- lib/bosh/monitor/plugins/pagerduty.rb
Constant Summary collapse
- API_URI =
"https://events.pagerduty.com/generic/2010-04-15/create_event.json"
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
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bosh/monitor/plugins/pagerduty.rb', line 22 def process(event) started = Time.now payload = { :service_key => ["service_key"], :event_type => "trigger", :incident_key => event.id, :description => event.short_description, :details => event.to_hash } request = { :body => Yajl::Encoder.encode(payload) } if ["http_proxy"] proxy = URI.parse(["http_proxy"]) request[:proxy] = { :host => proxy.host, :port => proxy.port } end send_http_post_request(API_URI, request) rescue => e logger.error("Error sending pagerduty event: #{e}") end |
#run ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/bosh/monitor/plugins/pagerduty.rb', line 8 def run unless EM.reactor_running? logger.error("Pagerduty plugin can only be started when event loop is running") return false end logger.info("Pagerduty delivery agent is running...") end |
#validate_options ⇒ Object
17 18 19 20 |
# File 'lib/bosh/monitor/plugins/pagerduty.rb', line 17 def .kind_of?(Hash) && ["service_key"].kind_of?(String) end |