class Remon::Metrics::Consul

Public Class Methods

new(host: "127.0.0.1", port: 8500) click to toggle source
# File lib/remon/metrics/consul.rb, line 8
def initialize(host: "127.0.0.1", port: 8500)
  @host = host
  @port = port
end

Public Instance Methods

failed_nodes() click to toggle source
# File lib/remon/metrics/consul.rb, line 13
def failed_nodes
  nodes = {}
  failed_serf_checks = critical_checks.select { |i| i["CheckID"] == "serfHealth" }
  failed_serf_checks.each { |i| nodes[i["Node"]] = i["Output"] }
  nodes
end

Private Instance Methods

consul_url(path) click to toggle source
# File lib/remon/metrics/consul.rb, line 22
def consul_url(path)
  "http://#{@host}:#{@port}#{path}"
end
critical_checks() click to toggle source
# File lib/remon/metrics/consul.rb, line 26
def critical_checks
  url = consul_url("/v1/health/state/critical")
  JSON.parse(open(url).read)
end