Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)

## [Unreleased]
### Added
- `check-s3-object.rb` - Added `--ok-no-file` option (@jaszka)

## 18.6.0
### Added
Expand Down
13 changes: 12 additions & 1 deletion bin/check-s3-object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ class CheckS3Object < Sensu::Plugin::Check::CLI
long: '--ok-on-multiple-objects',
boolean: true

option :ok_no_file,
description: 'OK if file with given prefix is not found',
long: '--ok-no-file',
boolean: true,
default: false

def aws_config
{ access_key_id: config[:aws_access_key],
secret_access_key: config[:aws_secret_access_key],
Expand Down Expand Up @@ -167,7 +173,12 @@ def run
output = output.next_page while output.next_page?

if output.contents.size.to_i < 1
critical "Object with prefix \"#{key_search}\" not found in bucket #{config[:bucket_name]}"
object_not_found = "Object with prefix \"#{key_search}\" not found in bucket #{config[:bucket_name]}"
if config[:ok_no_file]
ok object_not_found
else
critical object_not_found
end
end

if output.contents.size.to_i > 1
Expand Down