-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
specs for /collectd and /publish/:name
- Loading branch information
Showing
6 changed files
with
99 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,28 +7,15 @@ | |
|
||
module Backstop | ||
class Application < Sinatra::Base | ||
|
||
configure do | ||
enable :logging | ||
require 'newrelic_rpm' | ||
@@sockets = [] | ||
@@publisher = nil | ||
end | ||
|
||
helpers do | ||
def sockets | ||
if !@@sockets.empty? | ||
return @@sockets | ||
else | ||
@@sockets = [] | ||
Config.carbon_urls.each do |c| | ||
if (c =~ /^carbon:\/\//) | ||
c.gsub!(/carbon:\/\//, "") | ||
host, port = c.split(":") | ||
s = TCPSocket.new host, port | ||
@@sockets.push s | ||
end | ||
end | ||
end | ||
def publisher | ||
@@publisher ||= Backstop::Publisher.new(Config.carbon_urls) | ||
end | ||
end | ||
|
||
|
@@ -47,9 +34,8 @@ def sockets | |
results.each do |r| | ||
r["source"] = "collectd" | ||
halt 400, "missing fields" unless (r[:cloud] && r[:slot] && r[:id] && r[:metric] && r[:value] && r[:measure_time]) | ||
s = sockets.sample | ||
r[:cloud].gsub!(/\./, "-") | ||
s.puts "mitt.#{r[:cloud]}.#{r[:slot]}.#{r[:id]}.#{r[:metric]} #{r[:value]} #{r[:measure_time]}" if s | ||
publisher.publish("mitt.#{r[:cloud]}.#{r[:slot]}.#{r[:id]}.#{r[:metric]}", r[:value], r[:measure_time]) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tomkersten
|
||
end | ||
end | ||
"ok" | ||
|
@@ -85,14 +71,12 @@ def sockets | |
data.each do |item| | ||
item["source"] = params[:name] | ||
halt 400, "missing fields" unless (item['metric'] && item['value'] && item['measure_time']) | ||
s = sockets.sample | ||
s.puts "#{item['source']}.#{item['metric']} #{item['value']} #{item['measure_time']}" | ||
publisher.publish("#{item['source']}.#{item['metric']}", item['value'], item['measure_time']) | ||
end | ||
else | ||
data["source"] = params[:name] | ||
halt 400, "missing fields" unless (data['metric'] && data['value'] && data['measure_time']) | ||
s = sockets.sample | ||
s.puts "#{data['source']}.#{data['metric']} #{data['value']} #{data['measure_time']}" | ||
publisher.publish("#{data['source']}.#{data['metric']}", data['value'], data['measure_time']) | ||
end | ||
"ok" | ||
else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[ | ||
{ | ||
"values": [1901474177], | ||
"dstypes": ["counter"], | ||
"dsnames": ["value"], | ||
"interval": 10, | ||
"host": "leeloo.octo.it", | ||
"plugin": "cpu", | ||
"plugin_instance": "0", | ||
"type": "cpu", | ||
"type_instance": "idle" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"values": [1901474177], | ||
"dstypes": ["counter"], | ||
"dsnames": ["value"], | ||
"time": 1280959128, | ||
"interval": 10, | ||
"host": "leeloo.octo.it", | ||
"plugin": "cpu", | ||
"plugin_instance": "0", | ||
"type": "cpu", | ||
"type_instance": "idle" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
# This file was generated by the `rspec --init` command. Conventionally, all | ||
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. | ||
# Require this file using `require "spec_helper"` to ensure that it is only | ||
# loaded once. | ||
# | ||
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration | ||
require 'backstop' | ||
|
||
ENV['CARBON_URLS'] = 'carbon://1.1.1.1:5000' | ||
ENV['PREFIXES'] = 'test' | ||
|
||
RSpec.configure do |config| | ||
config.treat_symbols_as_metadata_keys_with_true_values = true | ||
config.run_all_when_everything_filtered = true | ||
config.filter_run :focus | ||
|
||
# Run specs in random order to surface order dependencies. If you find an | ||
# order dependency and want to debug it, you can fix the order by providing | ||
# the seed, which is printed after each run. | ||
# --seed 1234 | ||
config.order = 'random' | ||
end |
This may be a silly question, but, why the "mitt" prefix?