From d1080ccbbde9f80e8d10affe5a973cd20eb52eba Mon Sep 17 00:00:00 2001 From: xq2005 Date: Wed, 8 Dec 2010 08:14:17 +0000 Subject: [PATCH] monshow rmcmon -s command optimize git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8353 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-rmc/plugin/rmcmetrix.pm | 27 ++++++++++++++------------- xCAT-rmc/plugin/rmcmon.pm | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/xCAT-rmc/plugin/rmcmetrix.pm b/xCAT-rmc/plugin/rmcmetrix.pm index a4d3cfe56..8478c4be0 100755 --- a/xCAT-rmc/plugin/rmcmetrix.pm +++ b/xCAT-rmc/plugin/rmcmetrix.pm @@ -353,6 +353,7 @@ sub get_sum_metrix my $nodename = undef; my $time = undef; # my $end:shared; + my %summetrix = {}; my $end = undef; $end = xCAT::Utils->runcmd("date +%s", 0); # my $step:shared; @@ -420,8 +421,8 @@ sub get_sum_metrix # $summary{$a}{$n}{$timestamp} = &share({}); # $summary{$a}{$n}{$timestamp}{sum} = &share({}); # $summary{$a}{$n}{$timestamp}{num} = &share({}); - $summary{$a}{$n}{$timestamp}{sum} = $sum; - $summary{$a}{$n}{$timestamp}{num} = $num; + $summetrix{$a}{$timestamp}{sum} += $sum * $num; + $summetrix{$a}{$timestamp}{num} += $num; } } } @@ -435,18 +436,18 @@ sub get_sum_metrix # } # } - my %summetrix = {}; - foreach $attribute (keys %summary){ - foreach $nodename (keys %{$summary{$attribute}}){ - foreach $time (keys %{$summary{$attribute}{$nodename}}){ - print "$attribute.$nodename.$time $summary{$attribute}{$nodename}{$time}{sum} $summary{$attribute}{$nodename}{$time}{num}\n"; - $temp = $summary{$attribute}{$nodename}{$time}{sum} * $summary{$attribute}{$nodename}{$time}{num}; - $summetrix{$attribute}{$time}{sum} += $temp; - $summetrix{$attribute}{$time}{num} += $summary{$attribute}{$nodename}{$time}{num}; - } - } +# my %summetrix = {}; +# foreach $attribute (keys %summary){ +# foreach $nodename (keys %{$summary{$attribute}}){ +# foreach $time (keys %{$summary{$attribute}{$nodename}}){ +# print "$attribute.$nodename.$time $summary{$attribute}{$nodename}{$time}{sum} $summary{$attribute}{$nodename}{$time}{num}\n"; +# $temp = $summary{$attribute}{$nodename}{$time}{sum} * $summary{$attribute}{$nodename}{$time}{num}; +# $summetrix{$attribute}{$time}{sum} += $temp; +# $summetrix{$attribute}{$time}{num} += $summary{$attribute}{$nodename}{$time}{num}; +# } +# } - } +# } my $rrdcluster = "/var/rrd/cluster"; if(! -d $rrdcluster){ diff --git a/xCAT-rmc/plugin/rmcmon.pm b/xCAT-rmc/plugin/rmcmon.pm index a30ad8af5..cb02a72b8 100644 --- a/xCAT-rmc/plugin/rmcmon.pm +++ b/xCAT-rmc/plugin/rmcmon.pm @@ -1552,7 +1552,7 @@ sub showmetrix($rrddir, $attrs, $start_time, $end_time) if(! grep {/$timestamp/} @timelist){ push @timelist, $timestamp; } - $hash{$name}{$timestamp} = sprintf "%.4f", $sum/$num; + $hash{$name}{$timestamp} = sprintf "%.4f", $sum; } elsif ($line =~ /^(\d+): (\S+)/){ $timestamp = $1; $sum = $2;