Created
April 29, 2014 18:28
-
-
Save kbarber/11408243 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'net/http' | |
require 'uri' | |
require 'json' | |
require 'pp' | |
def store_report(report) | |
uri = URI.parse("http://localhost:8080/v3/commands") | |
http = Net::HTTP.new(uri.host, uri.port) | |
payload = { | |
"command" => "store report", | |
"version" => 3, | |
"payload" => report, | |
}.to_json | |
pp payload | |
headers = { 'Accept' => '*/*', 'Content-Type' => 'application/json' } | |
response = http.request_post(uri.request_uri, payload, headers) | |
puts response.body | |
end | |
report1 = { | |
"environment" => "foo", | |
"configuration-version"=>"heads/ction-0-gae6f3d1", | |
"end-time"=>"2014-01-27T15:34:15.781512000+00:00", | |
"transaction-uuid"=>"ce69013f-5f96-472b-b006-b80785d296ce", | |
"puppet-version"=>"3.4.2", | |
"start-time"=>"2014-01-27T15:32:55.481862000+00:00", | |
"report-format"=>4, | |
"resource-events"=> [ | |
{"timestamp"=>"2014-01-27T15:32:15.787270000+00:00", | |
"resource-type"=>"Notify", | |
"resource-title"=>"asdfasdfasdf", | |
"new-value"=>"mymessage", | |
"status"=>"success", | |
"message"=>"defined 'message' as 'mymessage'", | |
"line"=>4, | |
"old-value"=>"absent", | |
"file"=>"/etc/puppet/modules/my_foo/manifests/init.pp", | |
"containment-path"=>["Stage[main]", "My_foo", "Notify[asdfasdfasdf]"], | |
"property"=>"message"}, | |
{"timestamp"=>"2014-01-27T15:32:15.994853000+00:00", | |
"resource-type"=>"Exec", | |
"resource-title"=>"/bin/echo noop > /sys/block/sda/queue/scheduler", | |
"new-value"=>["0"], | |
"status"=>"success", | |
"message"=>"executed successfully", | |
"line"=>29, | |
"old-value"=>"notrun", | |
"file"=>"/etc/puppet/modules/my_pg/manifests/init.pp", | |
"containment-path"=> | |
["Stage[main]", | |
"My_pg", | |
"Exec[/bin/echo noop > /sys/block/sda/queue/scheduler]"], | |
"property"=>"returns"}, | |
{"timestamp"=>"2014-01-27T15:32:15.714112000+00:00", | |
"resource-type"=>"Notify", | |
"resource-title"=>"foo", | |
"new-value"=>"foo", | |
"status"=>"success", | |
"message"=>"defined 'message' as 'foo'", | |
"line"=>44, | |
"old-value"=>"absent", | |
"file"=>"/etc/puppet/manifests/nodes.pp", | |
"containment-path"=>["Stage[main]", "Main", "Notify[foo]"], | |
"property"=>"message"}, | |
{"timestamp"=>"2014-01-27T15:32:15.862427000+00:00", | |
"resource-type"=>"File", | |
"resource-title"=>"/dev/shm/pg", | |
"new-value"=>107, | |
"status"=>"success", | |
"message"=>"owner changed 'root' to 'postgres'", | |
"line"=>50, | |
"old-value"=>0, | |
"file"=>"/etc/puppet/modules/my_pg/manifests/init.pp", | |
"containment-path"=>["Stage[main]", "My_pg", "File[/dev/shm/pg]"], | |
"property"=>"owner"}, | |
], | |
"certname"=>"node-0" | |
} | |
store_report(report1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment