Sha256: 76349eac37282872949528d26f54e0384aabd761a1bfd90cc40548f7196faea3

Contents?: true

Size: 1.17 KB

Versions: 9

Compression:

Stored size: 1.17 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' }

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sensu-plugins-aws-4.0.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-3.2.1 bin/check-sns-subscriptions.rb
sensu-plugins-aws-3.2.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-3.1.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-3.0.0 bin/check-sns-subscriptions.rb
sensu-plugins-aws-2.4.3 bin/check-sns-subscriptions.rb
sensu-plugins-aws-2.4.2 bin/check-sns-subscriptions.rb
sensu-plugins-aws-2.4.1 bin/check-sns-subscriptions.rb
sensu-plugins-aws-2.4.0 bin/check-sns-subscriptions.rb