Sha256: a830506f0d1c2b6ebc2ca5c123cb551d886bcf04f0ac788b910e4506cd7a5f5c

Contents?: true

Size: 1.21 KB

Versions: 66

Compression:

Stored size: 1.21 KB

Contents

#! /usr/bin/env ruby
#
# check-sns-subscriptions
#
# DESCRIPTION:
#   This plugin checks if topics's subscriptions are not 'PendingConfirmation' state.
#
# OUTPUT:
#   plain-text
#
# PLATFORMS:
#   Linux
#
# DEPENDENCIES:
#   gem: aws-sdk
#   gem: sensu-plugin
#
# USAGE:
#   ./check-sns-subscriptions.rb --aws-region eu-west-1
#
# NOTES:
#
# LICENSE:
#   Copyright (c) 2016, Olivier Bazoud, olivier.bazoud@gmail.com
#   Released under the same terms as Sensu (the MIT license); see LICENSE
#   for details.
#

require 'sensu-plugin/check/cli'
require 'sensu-plugins-aws'
require 'aws-sdk'

class CheckSNSSubscriptions < Sensu::Plugin::Check::CLI
  include Common

  option :aws_region,
         short: '-r AWS_REGION',
         long: '--aws-region REGION',
         description: 'AWS Region (defaults to us-east-1).',
         default: 'us-east-1'

  def run
    sns = Aws::SNS::Client.new

    subscriptions = sns.list_subscriptions.subscriptions

    pending_confirmations = subscriptions.select { |subscription| subscription.subscription_arn == 'PendingConfirmation' }.map(&:topic_arn)

    critical "#{pending_confirmations.size} pending confirmations (#{pending_confirmations})" unless pending_confirmations.empty?
    ok
  end
end

Version data entries

66 entries across 66 versions & 2 rubygems

Version Path
sensu-plugins-aws-18.6.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-boutetnico-1.4.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-boutetnico-1.3.4 bin/check-sns-subscriptions.rb
sensu-plugins-aws-boutetnico-1.2.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-boutetnico-1.1.1 bin/check-sns-subscriptions.rb
sensu-plugins-aws-boutetnico-1.0.6 bin/check-sns-subscriptions.rb
sensu-plugins-aws-18.5.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-18.4.2 bin/check-sns-subscriptions.rb
sensu-plugins-aws-18.4.1 bin/check-sns-subscriptions.rb
sensu-plugins-aws-18.4.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-18.3.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-18.2.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-18.1.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-18.0.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-17.2.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-17.1.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-17.0.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-16.2.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-16.1.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-16.0.0 bin/check-sns-subscriptions.rb