Class: Pingdom::TMSSummary::Performance

Inherits:
Base
  • Object
show all
Defined in:
lib/pingdom/tms_summary/performance.rb

Overview

summary.performance includeuptime resolution=day

{
  "#"=>[
    {"avgresponse"=>994,"command"=>"Go to URL http://google.com",
    should be http://google.com"
  ],
  "avgresponse"=>1000,"downtime"=>0,"starttime"=>1500000000,"unmonitored"=>0,
  "uptime"=>86400,"revision"=>12345
}

]}

Defined Under Namespace

Classes: Ingredient

Constant Summary collapse

INTERVALS =
{
  "hour"  => 1.hour,
  "day"   => 1.day,
  "week"  => 1.week,
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attributes, check_error!, #id, #initialize, #inspect, #method_missing, #respond_to?, #respond_to_missing?

Constructor Details

This class inherits a constructor from Pingdom::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Pingdom::Base

Class Method Details

.parse(client, response) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/pingdom/tms_summary/performance.rb', line 29

def self.parse(client, response)
  body      = super["summary"]
  interval  = body.keys.detect { |k| INTERVALS.keys.include?(k.chomp("s").to_s) }.chomp("s").to_sym
  intervals = body[interval.to_s.pluralize]

  intervals.map do |perf|
    perf["interval"] = interval
    new(client, response, perf)
  end
end

Instance Method Details

#downtimeObject



59
60
61
# File 'lib/pingdom/tms_summary/performance.rb', line 59

def downtime
  @attributes["downtime"].seconds
end

#endtimeObject Also known as: end_at



50
51
52
# File 'lib/pingdom/tms_summary/performance.rb', line 50

def endtime
  starttime + INTERVALS[interval.to_s].to_i
end

#ingredientsObject Also known as: per_ingredient



40
41
42
# File 'lib/pingdom/tms_summary/performance.rb', line 40

def ingredients
  @attributes["#"].map { |ingredient| Ingredient.new @client, ingredient }
end

#monitoredObject



67
68
69
# File 'lib/pingdom/tms_summary/performance.rb', line 67

def monitored
  uptime + downtime
end

#periodObject



71
72
73
# File 'lib/pingdom/tms_summary/performance.rb', line 71

def period
  monitored + unmonitored
end

#starttimeObject Also known as: start_at



45
46
47
# File 'lib/pingdom/tms_summary/performance.rb', line 45

def starttime
  Time.at(@attributes["starttime"])
end

#unmonitoredObject



63
64
65
# File 'lib/pingdom/tms_summary/performance.rb', line 63

def unmonitored
  @attributes["unmonitored"].seconds
end

#uptimeObject



55
56
57
# File 'lib/pingdom/tms_summary/performance.rb', line 55

def uptime
  @attributes["uptime"].seconds
end