Sha256: 1010a2713387566f202709c8ce23607131ae208a6b06216926a9c26cbfd30593
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
#!/usr/bin/env ruby Process.setproctitle($0) require 'riemann/tools' $0 = __FILE__ # Let's not expose our AWS keys in the process list class Riemann::Tools::AWS include Riemann::Tools require 'fog' 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 if opts.has_key?('access_key') and opts.has_key?('secret_key') creds = { :aws_access_key_id => opts[:access_key], :aws_secret_access_key => opts[:secret_key] } else creds = { :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') ['ApproximateNumberOfMessages', 'ApproximateNumberOfMessagesNotVisible'].each do |attr| msg = { metric: response[:body]['Attributes'][attr], service: "#{opts[:queue]} #{attr}", state: 'ok' } report msg end end end Riemann::Tools::AWS.run
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
riemann-tools-1.0.0 | tools/riemann-aws/bin/riemann-aws-sqs-status |