Skip to content

Instantly share code, notes, and snippets.

@kbarber
Created February 20, 2014 19:41
Show Gist options
  • Select an option

  • Save kbarber/9121614 to your computer and use it in GitHub Desktop.

Select an option

Save kbarber/9121614 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'net/http'
require 'uri'
require 'json'
require 'facter'
uri = URI.parse("http://localhost:8080/v3/commands/")
http = Net::HTTP.new(uri.host, uri.port)
facts = {}
Facter.to_hash.each do |k,v|
facts[k] = v.to_s
end
def random_string
(0...50).map{ ('a'..'z').to_a[rand(26)] }.join
end
10000.times do
# Stringify to make sure RHS is a string
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data(
{
"payload" => {
"command" => "replace facts",
"version" => 1,
"payload" => {
"name" => random_string,
"values" => facts,
}.to_json,
}.to_json
}
)
response = http.request(request)
puts response.body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment