Skip to content

Commit

Permalink
Added a check for errors in the puppet run. (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
kindred authored and cwjohnston committed Jun 21, 2016
1 parent 919e847 commit e3db450
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
- check-puppet-last-run.rb: if the agent is disabled via lock file, display reason (if available)
- Loosened dependency on sensu-plugin from `= 1.2.0` to `~> 1.2.0`
- Updated Rubocop to 0.40, applied auto-correct
- Added a check for errors in the puppet run

### Removed
- Remove Ruby 1.9.3 support; add Ruby 2.2.0 and 2.3.0 support to test matrix.
Expand Down
7 changes: 6 additions & 1 deletion bin/check-puppet-last-run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def run
begin
summary = YAML.load_file(config[:summary_file])
@last_run = summary['time']['last_run'].to_i
@failures = summary['events']['failures'].to_i
rescue
unknown "Could not process #{config[:summary_file]}"
end
Expand All @@ -82,7 +83,11 @@ def run
# fail silently
end

if @now - @last_run > config[:crit_age]
if @failures > 0
@message += " with #{@failures} failures"
end

if @now - @last_run > config[:crit_age] || @failures > 0
critical @message
elsif @now - @last_run > config[:warn_age]
warning @message
Expand Down

0 comments on commit e3db450

Please sign in to comment.