Module: AWS::CloudWatch::EC2

Defined in:
lib/aws/cloud_watch/ec2.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/aws/cloud_watch/ec2.rb', line 35

def method_missing name, *args
  if [:disk_read_ops, :disk_write_ops, :network_out, :disk_read_bytes, :network_in, :disk_write_bytes].include?(name)
    metric = metrics[name]
    if args.length == 0
      metric
    else
      metric.sum *args
    end
  else
    super
  end
end

Instance Method Details

#cpu_utilization(*args) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/aws/cloud_watch/ec2.rb', line 26

def cpu_utilization *args
    metric = metrics['CPUUtilization']
    if args.length == 0
      metric
    else
      metric.average *args
    end
end

#metricsObject



22
23
24
# File 'lib/aws/cloud_watch/ec2.rb', line 22

def metrics
  @metrics ||= MetricCollection.new :namespace => 'AWS/EC2', :instance_id => id, :config => config
end