Last active
December 20, 2015 07:58
-
-
Save amosshapira/6096804 to your computer and use it in GitHub Desktop.
This script takes a list of names of Puppet report files and extract the names and time stamps of failed resources.
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 'yaml' | |
ARGV.each do |filename| | |
yaml = YAML.load_file(filename) | |
hash = yaml.ivars["resource_statuses"] | |
# The following line will just print the resource reference | |
# puts hash.keys.sort.select{|resource| hash[resource].ivars["failed"]} | |
# The following line will also print the resource time stamp, it demonstrates access | |
# to other fields about the resource in the report. | |
hash.keys.sort.select{|resource| hash[resource].ivars["failed"]}.each do |resource| | |
puts "#{hash[resource].ivars["time"]} #{resource}" | |
end | |
end | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment