Skip to content

Commit

Permalink
Bug #5080: ec2 1440 data points problem resolved (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Semedi Barranco authored and tinova committed Apr 25, 2017
1 parent 5a26817 commit 68f4b39
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/vmm_mad/remotes/ec2/ec2_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@
def handle_exception(action, ex, host, did, id = nil, file = nil)

file ||= ""
id ||= ""
id ||= ""
STDERR.puts action + " of VM #{id} #{did} on host #{host} #{file} "+
"due to \"#{ex.message}\""
STDERR.puts "********* STACK TRACE *********"
STDERR.puts ex.backtrace
STDERR.puts "*******************************"
exit (-1)
end




Expand Down Expand Up @@ -829,14 +828,20 @@ def cloudwatch_monitor_info(id, onevm, cw_mon_time)

# Get metric from AWS/EC2 namespace from the last poll
def get_cloudwatch_metric(cw, metric_name, last_poll, statistics, units, id)
options={:namespace=>"AWS/EC2",
:metric_name=>metric_name,
:start_time=> (Time.at(last_poll.to_i)-65).iso8601,
:end_time=> (Time.now-60).iso8601,
:period=>60,
:statistics=>statistics,
:unit=>units,
:dimensions=>[{:name=>"InstanceId", :value=>id}]}
dt = 60 # period
t0 = (Time.at(last_poll.to_i)-65) # last poll time
t = (Time.now-60) # actual time

while ((t - t0)/dt >= 1440) do dt+=60 end

options={:namespace=>"AWS/EC2",
:metric_name=>metric_name,
:start_time=> t0.iso8601,
:end_time=> t.iso8601,
:period=>dt,
:statistics=>statistics,
:unit=>units,
:dimensions=>[{:name=>"InstanceId", :value=>id}]}

cw.get_metric_statistics(options)
end
Expand Down

0 comments on commit 68f4b39

Please sign in to comment.