Hugh O. Brock
2008-Jun-07 14:40 UTC
[Ovirt-devel] graphing cleanup patch, committed this a.m.
ACKED and committed this this a.m. --Hugh -------------- next part -------------->From 94b68c3df4fff08562bd4abee80aeb3d70ec84c0 Mon Sep 17 00:00:00 2001 >From: Hugh O. Brock <hbrock at harpcolumn.com>Date: Sat, 7 Jun 2008 09:52:56 -0400 Subject: [PATCH] Numerous changes to connect graphs to something resembling live data thanks to Gentleman Genius Mark Wagner. Needs more tweaking, but this is a good start. Signed-off-by: Hugh O. Brock <hbrock at harpcolumn.com> Signed-off-by: Mark Wagner <mwagner at redhat.com> --- wui/src/app/controllers/graph_controller.rb | 40 ++++++++++++++------------- 1 files changed, 21 insertions(+), 19 deletions(-) diff --git a/wui/src/app/controllers/graph_controller.rb b/wui/src/app/controllers/graph_controller.rb index b02c93d..51db714 100644 --- a/wui/src/app/controllers/graph_controller.rb +++ b/wui/src/app/controllers/graph_controller.rb @@ -258,20 +258,12 @@ class GraphController < ApplicationController end elsif devClass == DEV_KEY_CLASSES["cpu"] if counter == DEV_KEY_AVGCOUNTERS["cpu"] - @snapshots[:avg]["cpu"] += value.to_i + @snapshots[:avg]["cpu"] += 100 - value.to_i @data_points[:avg]["cpu"] += 1 elsif counter == DEV_KEY_PEAKCOUNTERS["cpu"] - @snapshots[:peak]["cpu"] = value.to_i + @snapshots[:peak]["cpu"] = 100 - value.to_i @data_points[:peak]["cpu"] += 1 end - elsif devClass == DEV_KEY_CLASSES["netin"] - if counter == DEV_KEY_AVGCOUNTERS["netin"] - @snapshots[:avg]["netin"] += value.to_i - @data_points[:avg]["netin"] += 1 - elsif counter == DEV_KEY_PEAKCOUNTERS["netin"] - @snapshots[:peak]["netin"] += value.to_i - @data_points[:peak]["netin"] += 1 - end elsif devClass == DEV_KEY_CLASSES["netout"] if counter == DEV_KEY_AVGCOUNTERS["netout"] @snapshots[:avg]["netout"] += value.to_i @@ -279,13 +271,19 @@ class GraphController < ApplicationController elsif counter == DEV_KEY_PEAKCOUNTERS["netout"] @snapshots[:peak]["netout"] += value.to_i @data_points[:peak]["netout"] += 1 + elsif counter == DEV_KEY_AVGCOUNTERS["netin"] + @snapshots[:avg]["netin"] += value.to_i + @data_points[:avg]["netin"] += 1 + elsif counter == DEV_KEY_PEAKCOUNTERS["netin"] + @snapshots[:peak]["netin"] += value.to_i + @data_points[:peak]["netin"] += 1 end - elsif devClass == DEV_KEY_AVGCOUNTERS["memory"] + elsif devClass == DEV_KEY_CLASSES["memory"] if counter == DEV_KEY_AVGCOUNTERS["memory"] - @snapshots[:avg]["memory"] += value.to_i + @snapshots[:avg]["memory"] += (value.to_i / 1000000).to_i @data_points[:avg]["memory"] += 1 elsif counter == DEV_KEY_PEAKCOUNTERS["memory"] - @snapshots[:peak]["memory"] += value.to_i + @snapshots[:peak]["memory"] += (value.to_i / 1000000).to_i @data_points[:peak]["memory"] += 1 end end @@ -297,6 +295,10 @@ class GraphController < ApplicationController } @snapshots.each_key { |k| @snapshots[k]['load'] /= @data_points[k]['load'] if @data_points[k]['load'] != 0 + @snapshots[k]['cpu'] /= @data_points[k]['cpu'] if @data_points[k]['cpu'] != 0 + @snapshots[k]['memory'] /= @data_points[k]['memory'] if @data_points[k]['memory'] != 0 + @snapshots[k]['netin'] /= @data_points[k]['netin'] if @data_points[k]['netin'] != 0 + @snapshots[k]['netout'] /= @data_points[k]['netout'] if @data_points[k]['netout'] != 0 } #@snapshots = { :avg => { :overall_load => 500, :cpu => 10, :in => 100, :out => 1024, :io => 200 }, # :peak => { :overall_load => 100, :cpu => 50, :in => 12, :out => 72, :io => 100 } } @@ -309,7 +311,7 @@ class GraphController < ApplicationController DEV_CLASS_KEYS = DEV_KEY_CLASSES.invert # TODO this needs fixing / completing (cpu: more than user time? disk: ?, load: correct?, nics: correct?) - DEV_KEY_AVGCOUNTERS = { 'cpu' => CpuCounter::User, 'memory' => MemCounter::Used, 'disk' => DiskCounter::Ops_read, 'load' => LoadCounter::Load_1min, 'netin' => NicCounter::Packets_Rx, 'netout' => NicCounter::Packets_Tx } + DEV_KEY_AVGCOUNTERS = { 'cpu' => CpuCounter::Idle, 'memory' => MemCounter::Used, 'disk' => DiskCounter::Ops_read, 'load' => LoadCounter::Load_1min, 'netin' => NicCounter::Octets_rx, 'netout' => NicCounter::Octets_tx } DEV_AVGCOUNTER_KEYS = DEV_KEY_AVGCOUNTERS.invert # TODO @@ -318,11 +320,11 @@ class GraphController < ApplicationController def _create_host_snapshot_requests(hostname) requestList = [] - requestList << StatsRequest.new(hostname, DEV_KEY_CLASSES['load'], 0, DEV_KEY_AVGCOUNTERS['load'], 0, 0, RRDResolution::Default) # RRDResolution::Long ? - requestList << StatsRequest.new(hostname, DEV_KEY_CLASSES['cpu'], 0, DEV_KEY_AVGCOUNTERS['cpu'], 0, 0, RRDResolution::Default) - requestList << StatsRequest.new(hostname, DEV_KEY_CLASSES['netin'],0, DEV_KEY_AVGCOUNTERS['netin'], 0, 0, RRDResolution::Default) - requestList << StatsRequest.new(hostname, DEV_KEY_CLASSES['netout'],0, DEV_KEY_AVGCOUNTERS['netout'], 0, 0, RRDResolution::Default) - requestList << StatsRequest.new(hostname, DEV_KEY_CLASSES["memory"],0, DEV_KEY_AVGCOUNTERS["memory"], 0, 0, RRDResolution::Default) + requestList << StatsRequest.new(hostname, DEV_KEY_CLASSES['memory'],0, DEV_KEY_AVGCOUNTERS['memory'], 0, 3600, RRDResolution::Medium) + requestList << StatsRequest.new(hostname, DEV_KEY_CLASSES['load'], 0, DEV_KEY_AVGCOUNTERS['load'], 0, 3600, RRDResolution::Medium) # RRDResolution::Long ? + requestList << StatsRequest.new(hostname, DEV_KEY_CLASSES['cpu'], 0, DEV_KEY_AVGCOUNTERS['cpu'], 0, 3600, RRDResolution::Medium) + requestList << StatsRequest.new(hostname, DEV_KEY_CLASSES['netout'],0, DEV_KEY_AVGCOUNTERS['netout'], 0, 3600, RRDResolution::Medium) + requestList << StatsRequest.new(hostname, DEV_KEY_CLASSES['netin'],0, DEV_KEY_AVGCOUNTERS['netin'], 0, 3600, RRDResolution::Medium) return requestList end -- 1.5.5.1