Class: OpenStudioCloudWatch
- Inherits:
-
Object
- Object
- OpenStudioCloudWatch
- Includes:
- Logging
- Defined in:
- lib/openstudio/lib/openstudio_cloud_watch.rb
Constant Summary collapse
- VALID_OPTIONS =
[:proxy, :credentials]
Instance Attribute Summary collapse
-
#private_key_file_name ⇒ Object
Returns the value of attribute private_key_file_name.
-
#security_groups ⇒ Object
Returns the value of attribute security_groups.
Instance Method Summary collapse
- #estimated_charges ⇒ Object
-
#initialize(options = {}) ⇒ OpenStudioCloudWatch
constructor
A new instance of OpenStudioCloudWatch.
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( = {}) # store an instance variable with the proxy for passing to instances for use in scp/ssh @proxy = [:proxy] ? [:proxy] : nil # need to remove the prxoy information here @aws = Aws::CloudWatch::Client.new([:credentials]) end |
Instance Attribute Details
#private_key_file_name ⇒ Object
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_groups ⇒ Object
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_charges ⇒ Object
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 |