Sha256: 66b71bad477a1a445ce8290bea97189cbde399e1da170afbd5ffbea95b96b170
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true require 'riemann/tools' module Riemann module Tools module Aws class SqsStatus include Riemann::Tools require 'fog/aws' opt :access_key, 'AWS access key', type: String opt :secret_key, 'Secret access key', type: String opt :region, 'AWS region', type: String, default: 'us-east-1' opt :queue, 'SQS Queue name', type: String def initialize super creds = if opts.key?('access_key') && opts.key?('secret_key') { aws_access_key_id: opts[:access_key], aws_secret_access_key: opts[:secret_key], } else { use_iam_profile: true } end creds['region'] = opts[:region] @sqs = Fog::AWS::SQS.new(creds) response = @sqs.list_queues({ 'QueueNamePrefix' => opts[:queue] }) @queue_url = response[:body]['QueueUrls'].first end def tick response = @sqs.get_queue_attributes(@queue_url, 'All') %w[ApproximateNumberOfMessages ApproximateNumberOfMessagesNotVisible].each do |attr| msg = { metric: response[:body]['Attributes'][attr], service: "#{opts[:queue]} #{attr}", state: 'ok', } report msg end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
riemann-tools-1.11.0 | tools/riemann-aws/lib/riemann/tools/aws/sqs_status.rb |