class Riemann::Tools::Cloudant
Public Instance Methods
json()
click to toggle source
# File lib/riemann/tools/cloudant.rb, line 47 def json http = ::Net::HTTP.new('cloudant.com', 443) http.use_ssl = true http.start do |h| get = ::Net::HTTP::Get.new('/api/load_balancer', { 'user-agent' => opts[:user_agent] }) get.basic_auth opts[:cloudant_username], opts[:cloudant_password] h.request get end JSON.parse(http.boby) end
tick()
click to toggle source
# File lib/riemann/tools/cloudant.rb, line 18 def tick json.each do |node| break if node['svname'] == 'BACKEND' # this is just a sum of all nodes. ns = "cloudant #{node['pxname']}" cluster_name = node['tracked'].split('.')[0] # ie: meritage.cloudant.com # report health of each node. report( service: ns, state: (node['status'] == 'UP' ? 'ok' : 'critical'), tags: ['cloudant', cluster_name], ) # report property->metric of each node. node.each do |property, metric| next if %w[pxname svname status tracked].include?(property) report( host: node['tracked'], service: "#{ns} #{property}", metric: metric.to_f, state: (node['status'] == 'UP' ? 'ok' : 'critical'), tags: ['cloudant', cluster_name], ) end end end