Class: God::Contacts::Statsd
- Inherits:
-
God::Contact
- Object
- God::Contact
- God::Contacts::Statsd
- Defined in:
- lib/god/contacts/statsd.rb
Class Attribute Summary collapse
-
.host ⇒ Object
Returns the value of attribute host.
-
.port ⇒ Object
Returns the value of attribute port.
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
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
.host ⇒ Object
Returns the value of attribute host.
13 14 15 |
# File 'lib/god/contacts/statsd.rb', line 13 def host @host end |
.port ⇒ Object
Returns the value of attribute port.
13 14 15 |
# File 'lib/god/contacts/statsd.rb', line 13 def port @port end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
16 17 18 |
# File 'lib/god/contacts/statsd.rb', line 16 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
16 17 18 |
# File 'lib/god/contacts/statsd.rb', line 16 def port @port end |
Instance Method Details
#notify(message, time, priority, category, hostname) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/god/contacts/statsd.rb', line 24 def notify(, time, priority, category, hostname) statsd = ::Statsd.new host, (port ? port.to_i : 8125) # 8125 is the default statsd port hostname.gsub! /\./, '_' app = .gsub /([^\s]*).*/, '\1' [ 'cpu out of bounds', 'memory out of bounds', 'process is flapping' ].each do |event_type| statsd.increment "god.#{event_type.gsub(/\s/, '_')}.#{hostname}.#{app}" if .include? event_type end self.info = 'sent statsd alert' rescue => e applog(nil, :info, "failed to send statsd alert: #{e.}") applog(nil, :debug, e.backtrace.join("\n")) end |
#valid? ⇒ Boolean
18 19 20 21 22 |
# File 'lib/god/contacts/statsd.rb', line 18 def valid? valid = true valid &= complain("Attribute 'statsd_host' must be specified", self) unless arg(:host) valid end |