Module: DashingContrib::Pingdom::Checks

Extended by:
Checks
Included in:
Checks
Defined in:
lib/dashing-contrib/bottles/pingdom/checks.rb

Instance Method Summary collapse

Instance Method Details

#fetch(credentials, id) ⇒ Object



9
10
11
# File 'lib/dashing-contrib/bottles/pingdom/checks.rb', line 9

def fetch(credentials, id)
  make_request(credentials, id)
end

#summary(credentials) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dashing-contrib/bottles/pingdom/checks.rb', line 13

def summary(credentials)
  checks = make_request(credentials, nil)
  states = { 'up'               => { checks: { }, value: 0 },
             'down'             => { checks: { }, value: 0 },
             'unconfirmed_down' => { checks: { }, value: 0 },
             'unknown'          => { checks: { }, value: 0 },
             'paused'           => { checks: { }, value: 0 }
           }

  checks[:checks].each { |check|
    states[check[:status]] = { checks: states[check[:status]][:checks], value: (states[check[:status]][:value] + 1) }
    if check.has_key?(:lasterrortime)
      states[check[:status]][:checks][check[:lasterrortime]] = check[:name]
    elsif check.has_key?(:lasttesttime)
      states[check[:status]][:checks][check[:lasttesttime]] = check[:name]
    end
  }
  return states
end