Class: Scout::Plugin
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Scout::Plugin
- Defined in:
- lib/scout_api/plugin.rb
Instance Attribute Summary collapse
-
#descriptor_hash ⇒ Object
readonly
:nodoc:.
-
#metrics ⇒ Object
readonly
Retrieve metric information.
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
- #email_subscribers ⇒ Object
-
#initialize(hash, ignore = nil) ⇒ Plugin
constructor
2nd parameter is ignored/a hack because of this open Hashie issue: github.com/intridea/hashie/issues/14.
- #triggers ⇒ Object
Constructor Details
#initialize(hash, ignore = nil) ⇒ Plugin
2nd parameter is ignored/a hack because of this open Hashie issue: github.com/intridea/hashie/issues/14
40 41 42 43 44 45 46 47 |
# File 'lib/scout_api/plugin.rb', line 40 def initialize(hash, ignore = nil) #:nodoc: if hash['descriptors'] && hash['descriptors']['descriptor'] @descriptor_hash = hash['descriptors']['descriptor'] hash.delete('descriptors') end @metrics = Scout::MetricProxy.new(self) super(hash) end |
Instance Attribute Details
#descriptor_hash ⇒ Object (readonly)
:nodoc:
37 38 39 |
# File 'lib/scout_api/plugin.rb', line 37 def descriptor_hash @descriptor_hash end |
#metrics ⇒ Object (readonly)
Retrieve metric information. See Metric.average for a list of options for the calculation methods (average, minimum, maximum).
Examples:
# All metrics associated with this plugin.
Scout::Plugin.metrics
# Metrics with name =~ 'Memory Used' on this plugin.
Scout::Plugin.metrics.all(:name => 'Memory Used')
# Average value of metrics with name =~ 'Memory Used' on this plugin.
Scout::Plugin.metrics.average(:name => 'Memory Used')
# Maximum value...
Scout::Plugin.metrics.maximum(:name => 'Memory Used')
# Minumum value...
Scout::Plugin.metrics.minimum(:name => 'Memory Used')
# Sum metrics, then take average
Scout::Plugin.metrics.average(:name => 'request_rate', :aggregate => true)
# Retrieve data starting @ 5 hours ago ending at 2 hours ago
Scout::Plugin.metrics.average(:name => 'request_rate', :start => Time.now.utc-5*3600, :end => Time.now.utc-2*3600)
# An array of time series values over the past hour
Scout::Plugin.metrics.average(:name => 'Memory Used').to_array
# A Url to a Google Sparkline Chart.
Scout::Plugin.metrics.average(:name => 'Memory Used').to_sparkline
35 36 37 |
# File 'lib/scout_api/plugin.rb', line 35 def metrics @metrics end |
#server ⇒ Object
Returns the value of attribute server.
2 3 4 |
# File 'lib/scout_api/plugin.rb', line 2 def server @server end |
Instance Method Details
#email_subscribers ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/scout_api/plugin.rb', line 49 def email_subscribers response = Scout::Account.get("/clients/#{server.id}/email_subscribers?plugin_id=#{id}") doc = Nokogiri::HTML(response.body) table = doc.css('table.list').first user_rows = table.css('tr')[1..-1] # skip first row, which is headings user_rows.map do |row| name_td, receiving_notifications_td = *row.css('td') name = name_td.content.gsub(/[\t\n]/, '') checked = receiving_notifications_td.css('input').attribute('checked') receiving_notifications = checked && checked.value == 'checked' Hashie::Mash.new :name => name, :receiving_notifications => receiving_notifications end end |