Class: Riemann::Tools::Cloudant
- Inherits:
-
Object
- Object
- Riemann::Tools::Cloudant
show all
- Includes:
- Riemann::Tools
- Defined in:
- lib/riemann/tools/cloudant.rb
Constant Summary
VERSION
Instance Attribute Summary
#argv
Instance Method Summary
collapse
#attributes, #endpoint_name, included, #initialize, #options, #report, #riemann, #run
Instance Method Details
#json ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# 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 ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/riemann/tools/cloudant.rb', line 18
def tick
json.each do |node|
break if node['svname'] == 'BACKEND'
ns = "cloudant #{node['pxname']}"
cluster_name = node['tracked'].split('.')[0]
report(
service: ns,
state: (node['status'] == 'UP' ? 'ok' : 'critical'),
tags: ['cloudant', cluster_name],
)
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
|