Class: OpenStudioCloudWatch

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/openstudio/lib/openstudio_cloud_watch.rb

Constant Summary collapse

VALID_OPTIONS =
[:proxy, :credentials]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

configure_logger_for, #logger, logger_for

Constructor Details

#initialize(options = {}) ⇒ OpenStudioCloudWatch

Returns a new instance of OpenStudioCloudWatch.



46
47
48
49
50
51
52
# File 'lib/openstudio/lib/openstudio_cloud_watch.rb', line 46

def initialize(options = {})
  # store an instance variable with the proxy for passing to instances for use in scp/ssh
  @proxy = options[:proxy] ? options[:proxy] : nil

  # need to remove the prxoy information here
  @aws = Aws::CloudWatch::Client.new(options[:credentials])
end

Instance Attribute Details

#private_key_file_nameObject

Returns the value of attribute private_key_file_name.



41
42
43
# File 'lib/openstudio/lib/openstudio_cloud_watch.rb', line 41

def private_key_file_name
  @private_key_file_name
end

#security_groupsObject

Returns the value of attribute security_groups.



42
43
44
# File 'lib/openstudio/lib/openstudio_cloud_watch.rb', line 42

def security_groups
  @security_groups
end

Instance Method Details

#estimated_chargesObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/openstudio/lib/openstudio_cloud_watch.rb', line 54

def estimated_charges
  end_time = Time.now.utc
  start_time = end_time - 86400
  resp = @aws.get_metric_statistics(
    dimensions: [
      { name: 'ServiceName', value: 'AmazonEC2' },
      { name: 'Currency', value: 'USD' }],
    metric_name: 'EstimatedCharges',
    namespace: 'AWS/Billing',
    start_time: start_time.iso8601,
    end_time: end_time.iso8601,
    period: 300,
    statistics: ['Maximum']
  )

  resp.data || []
end