Sha256: c2b0e9fbe151fd51e6202940e9870ccc4c6f1dcf94fa0a14963a302e34a7e155

Contents?: true

Size: 1.99 KB

Versions: 2

Compression:

Stored size: 1.99 KB

Contents

#!/usr/bin/env ruby

begin
  require 'zabbix-cloudwatch'
  require 'getopt/long'
rescue
  require 'rubygems'
  require 'zabbix-cloudwatch'
  require 'getopt/long'
end

@@aws_access_key=''
@@aws_secret_key=''
@@aws_region=''


class RubyVersionException < StandardError; end

raise RubyVersionException, "Ruby version must be 1.8.7" unless RUBY_VERSION == "1.8.7"

opts = Getopt::Long.getopts(
   ["--help"],
   ["--namespace",  Getopt::REQUIRED],
   ["--metricname", Getopt::REQUIRED],
   ["--dimension-name",  Getopt::REQUIRED],
   ["--dimension-value","-v",  Getopt::REQUIRED],
   ["--monitoring-type", "-t", Getopt::REQUIRED],
   ["--statistic",Getopt::REQUIRED],
   ["--aws-access-key", Getopt::REQUIRED],
   ["--aws-secret-key", Getopt::REQUIRED],
   ["--aws-region", Getopt::REQUIRED]
)


def usage
  puts <<EOF
Usage: #{$0}

  -h, --help              This Message
  -n, --namespace         Namespace (AWS/Autoscaling, AWS/EC2, etc...)
  -m, --metricname        Metric Name (GroupInServiceInstances,EstimatedCharges, etc...)
  -d, --dimension-name    Dimension Name (AutoScalingGroupName, etc...)
  -v, --dimension-value   Dimension Value
  -t, --monitoring-type   detailed|basic                            Default: basic
  -s, --statistic         Minimum|Maximum|Average|Sum|SampleCount   Default: Average
  --aws-access-key        AWS Access Key
  --aws-secret-key        AWS Secret Key
  --aws-region            AWS Region (us-east-1)                    Default: us-east-1

EOF
  exit 1
end

if opts.key?"help" or opts.empty?
  usage
  exit 0
end

unless opts.key?"aws-access-key"
  opts["aws-access-key"] = (@@aws_access_key == '' && ENV["AWS_ACCESS_KEY_ID"])     || @@aws_access_key
end
unless opts.key?"aws-secret-key"
  opts["aws-secret-key"] = (@@aws_secret_key == '' && ENV["AWS_SECRET_ACCESS_KEY"]) || @@aws_secret_key
end
unless opts.key?"aws-region"
  opts["aws-region"] = (@@aws_region     == '' && ENV["AWS_REGION"])            || @@aws_region
end

inst = ZabbixCloudwatch::GetCloudwatchMetric.new(opts)
inst.run!

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zabbix-cloudwatch-0.0.4 bin/zabbix-cloudwatch
zabbix-cloudwatch-0.0.3 bin/zabbix-cloudwatch