Last active
December 2, 2017 00:27
-
-
Save ipcrm/164298c98eafeabb862d5eea3da24239 to your computer and use it in GitHub Desktop.
Ruby: Query PDB Report Data
This file contains hidden or 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
require 'puppetdb' | |
client = PuppetDB::Client.new({:server => 'http://localhost:8080'}) | |
response = client.request( '', 'reports[certname,logs]{ latest_report? = true and facts { name = "role" and value = "test" } }') | |
response.data.each do |c| | |
c["logs"]["data"].each do |l| | |
printf "%-30s %s\n" % [ c["certname"].rstrip(), l["message"].split(/[\[,\]]/)[1] ] if l["message"].include?('Echo') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example output