Sha256: 9d7c099667dd7f190f721ec5715d9de8a6f8fdce6ae6b0599c51a3aa0263553f

Contents?: true

Size: 1.59 KB

Versions: 73

Compression:

Stored size: 1.59 KB

Contents

#! /usr/bin/env ruby
#
# metrics-ses
#
# DESCRIPTION:
#   Lists SES send statistics
#
# OUTPUT:
#   metric data
#
# DEPENDENCIES:
#   gem: aws-sdk
#   gem: sensu-plugin
#
# USAGE:
#   metrics-ses.rb -r us-west-2
#
#   This will list out the statistics for the most recent 15 minutes from SES
#
# NOTES:
#
# LICENSE:
#   Brandon Smith <freedom@reardencode.com>
#   Released under the same terms as Sensu (the MIT license); see LICENSE
#   for details.

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

class SesMetrics < Sensu::Plugin::Metric::CLI::Graphite
  include Common

  option :scheme,
         description: 'Metric naming scheme, text to prepend to metric',
         short: '-s SCHEME',
         long: '--scheme SCHEME',
         default: 'sensu.aws.ses'

  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
    ses = Aws::SES::Client.new(aws_config)
    begin
      response = ses.get_send_statistics

      unknown 'Empty response from AWS SES API' if response.empty? # Can this happen?
      unknown 'No data points from AWS SES API' if response.send_data_points.empty?

      data_point = response.send_data_points.sort_by(&:timestamp).last
      output config[:scheme] + '.bounces', data_point.bounces
      output config[:scheme] + '.rejects', data_point.rejects
      output config[:scheme] + '.complaints', data_point.complaints
      output config[:scheme] + '.delivery_attempts', data_point.delivery_attempts
    end
    ok
  end
end

Version data entries

73 entries across 73 versions & 2 rubygems

Version Path
sensu-plugins-aws-10.1.2 bin/metrics-ses.rb
sensu-plugins-aws-10.1.1 bin/metrics-ses.rb
sensu-plugins-aws-10.1.0 bin/metrics-ses.rb
sensu-plugins-aws-10.0.3 bin/metrics-ses.rb
sensu-plugins-aws-10.0.2 bin/metrics-ses.rb
sensu-plugins-aws-10.0.1 bin/metrics-ses.rb
sensu-plugins-aws-10.0.0 bin/metrics-ses.rb
sensu-plugins-aws-9.0.1 bin/metrics-ses.rb
sensu-plugins-aws-9.0.0 bin/metrics-ses.rb
sensu-plugins-aws-8.3.1 bin/metrics-ses.rb
sensu-plugins-aws-8.3.0 bin/metrics-ses.rb
sensu-plugins-aws-8.2.0 bin/metrics-ses.rb
sensu-plugins-aws-8.1.0 bin/metrics-ses.rb
sensu-plugins-aws-8.0.0 bin/metrics-ses.rb
sensu-plugins-aws-7.1.0 bin/metrics-ses.rb
sensu-plugins-aws-7.0.1 bin/metrics-ses.rb
sensu-plugins-aws-7.0.0 bin/metrics-ses.rb
sensu-plugins-aws-6.3.0 bin/metrics-ses.rb
sensu-plugins-aws-6.2.0 bin/metrics-ses.rb
sensu-plugins-aws-6.1.1 bin/metrics-ses.rb