Alexandros Kosiaris has uploaded a new change for review. https://gerrit.wikimedia.org/r/305487
Change subject: check_puppetrun: Add reportfile handling ...................................................................... check_puppetrun: Add reportfile handling Report failed resources if any exist. Parse the reportfile, get the failed resources and print them in the output. Use safe_yaml to avoid deserialization of the ruby objects in the reportfile. The gem is installed as a prereq of the puppet Debian package. Change-Id: I98ad9f9dd46c40c05f0ca9a527a67fb605ef85cd --- M modules/base/files/monitoring/check_puppetrun 1 file changed, 10 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/87/305487/1 diff --git a/modules/base/files/monitoring/check_puppetrun b/modules/base/files/monitoring/check_puppetrun index 7026a69..6abd6d0 100755 --- a/modules/base/files/monitoring/check_puppetrun +++ b/modules/base/files/monitoring/check_puppetrun @@ -9,11 +9,12 @@ # file to determine when last Puppet ran require 'optparse' -require 'yaml' +require 'safe_yaml' runlockfile = "/var/lib/puppet/state/agent_catalog_run.lock" adminlockfile = "/var/lib/puppet/state/agent_disabled.lock" summaryfile = "/var/lib/puppet/state/last_run_summary.yaml" +reportfile = "/var/lib/puppet/state/last_run_report.yaml" enabled = true running = false lastrun = 0 @@ -21,6 +22,7 @@ warn = 0 crit = 0 enabled_only = false +SafeYAML::OPTIONS[:default_mode] = :safe opt = OptionParser.new @@ -46,6 +48,10 @@ opt.on("--summary-file [FILE]", "-s", "Location of the summary file, default #{summaryfile}") do |f| summaryfile = f +end + +opt.on("--report-file [FILE]", "-r", "Location of the report file, default #{reportfile}") do |f| + reportfile = f end opt.parse! @@ -121,7 +127,9 @@ end if failcount > 0 - puts "CRITICAL: Puppet has #{failcount} failures" + report = YAML.load_file(reportfile) + failed_resources = report["resource_statuses"].select { |_,r| r["failed"] }.map { |_,r| r["resource"] } + puts "CRITICAL: Puppet has #{failcount} failures. Failed resources: #{failed_resources.join','}" exit 2 end -- To view, visit https://gerrit.wikimedia.org/r/305487 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I98ad9f9dd46c40c05f0ca9a527a67fb605ef85cd Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Alexandros Kosiaris <akosia...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits