From e1d6264ea88a0b64c8cb13704cb9a418bc1e0718 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 14 Sep 2011 18:06:03 +0200 Subject: [PATCH] bug #716: Fix bug in host monitoring client(cherry picked from commit 16424e9a52632b734af6de789c8b168caf78319c) --- src/acct/watch_client.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/acct/watch_client.rb b/src/acct/watch_client.rb index 36efadb078..0ff9c4f7c0 100644 --- a/src/acct/watch_client.rb +++ b/src/acct/watch_client.rb @@ -97,18 +97,11 @@ module OneWatchClient # Get the MAX for each VM and last_poll value max_per_vm = rsql. - group(:vm_id, :timestamp). - select{[:timestamp, max(mr.to_sym).as(:max_mr)]} - - # SUM the monitoring resource for each last_poll value - last_poll_and_sum = - max_per_vm. - from_self. group(:timestamp). - select{[:timestamp, sum(:max_mr).as(:sum_mr)]} + select{[:timestamp, sum(mr.to_sym).as(:sum_mr)]} # Add all the existing timestamps - with_ts = timestamps.left_join(last_poll_and_sum, :timestamp=>:id) + with_ts = timestamps.left_join(max_per_vm, :timestamp=>:id) with_ts.collect do |row| [row[:id], row[:sum_mr].to_i] end @@ -166,7 +159,7 @@ module OneWatchClient hosts = pool end - WatchHelper::HostSample.join(vms.select(:id.as(:host_id)), [:host_id]) + WatchHelper::HostSample.join(hosts.select(:id.as(:host_id)), [:host_id]) end def filter_resource(id, filter)