Class: God::Contacts::Scout
- Inherits:
-
God::Contact
- Object
- God::Contact
- God::Contacts::Scout
- Defined in:
- lib/god/contacts/scout.rb
Class Attribute Summary collapse
-
.client_key ⇒ Object
Returns the value of attribute client_key.
-
.format ⇒ Object
Returns the value of attribute format.
-
.plugin_id ⇒ Object
Returns the value of attribute plugin_id.
Instance Attribute Summary collapse
-
#client_key ⇒ Object
Returns the value of attribute client_key.
-
#plugin_id ⇒ Object
Returns the value of attribute plugin_id.
Attributes inherited from God::Contact
Instance Method Summary collapse
Methods inherited from God::Contact
#arg, defaults, #friendly_name, generate, normalize, valid?
Methods included from God::Configurable
#base_name, complain, #complain, #friendly_name, #prepare, #reset
Class Attribute Details
.client_key ⇒ Object
Returns the value of attribute client_key.
14 15 16 |
# File 'lib/god/contacts/scout.rb', line 14 def client_key @client_key end |
.format ⇒ Object
Returns the value of attribute format.
15 16 17 |
# File 'lib/god/contacts/scout.rb', line 15 def format @format end |
.plugin_id ⇒ Object
Returns the value of attribute plugin_id.
14 15 16 |
# File 'lib/god/contacts/scout.rb', line 14 def plugin_id @plugin_id end |
Instance Attribute Details
#client_key ⇒ Object
Returns the value of attribute client_key.
26 27 28 |
# File 'lib/god/contacts/scout.rb', line 26 def client_key @client_key end |
#plugin_id ⇒ Object
Returns the value of attribute plugin_id.
26 27 28 |
# File 'lib/god/contacts/scout.rb', line 26 def plugin_id @plugin_id end |
Instance Method Details
#notify(message, time, priority, category, host) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/god/contacts/scout.rb', line 35 def notify(, time, priority, category, host) data = { :client_key => arg(:client_key), :plugin_id => arg(:plugin_id), :format => 'xml', 'alert[subject]' => , 'alert[body]' => Scout.format.call(, priority, category, host) } uri = URI.parse('http://scoutapp.com/alerts/create') Net::HTTP.post_form(uri, data) self.info = "sent scout alert to plugin ##{plugin_id}" rescue => e applog(nil, :info, "failed to send scout alert to plugin ##{plugin_id}: #{e.}") applog(nil, :debug, e.backtrace.join("\n")) end |
#valid? ⇒ Boolean
28 29 30 31 32 33 |
# File 'lib/god/contacts/scout.rb', line 28 def valid? valid = true valid &= complain("Attribute 'client_key' must be specified", self) unless arg(:client_key) valid &= complain("Attribute 'plugin_id' must be specified", self) unless arg(:plugin_id) valid end |