[Ovirt-devel] [PATCH] resubmitting stats package updates

Steve Linabery slinabery at redhat.com
Thu Aug 28 05:37:02 UTC 2008


These are the changes to the stats package files that I submitted previously on behalf of Mark Wagner (as part of a patch for review/comment). I believe these are pretty straightforward & would appreciate some ack-age on these, since the stuff I'm working on now depends on them.

Thanks,
Steve
-------------- next part --------------
>From 417cd9ff0f24f1abf6f2c1349bea1c7e6b1244a5 Mon Sep 17 00:00:00 2001
From: Steve Linabery <slinabery at redhat.com>
Date: Wed, 27 Aug 2008 21:02:30 -0500
Subject: [PATCH] Add changes to stats package components

On behalf of Mark Wagner
---
 wui/src/app/util/stats/Stats.rb         |   77 +++++++++++++++++++++++++++----
 wui/src/app/util/stats/StatsDataList.rb |   74 +++++++++++++++++++----------
 wui/src/app/util/stats/statsTest.rb     |   50 ++++++++++++--------
 3 files changed, 146 insertions(+), 55 deletions(-)

diff --git a/wui/src/app/util/stats/Stats.rb b/wui/src/app/util/stats/Stats.rb
index f6ced4b..2e2e966 100644
--- a/wui/src/app/util/stats/Stats.rb
+++ b/wui/src/app/util/stats/Stats.rb
@@ -29,6 +29,8 @@ require 'util/stats/StatsRequest'
 
 def fetchRollingAve?(rrdPath, start, endTime, interval, myFunction, lIndex, returnList, aveLen=7)
    final = 0
+   my_min = 0
+   my_max = 0
 
    #  OK, first thing we need to do is to move the start time back in order to 
    #  have data to average.
@@ -55,7 +57,6 @@ def fetchRollingAve?(rrdPath, start, endTime, interval, myFunction, lIndex, retu
       value = 0
       value = vdata[lIndex]
       value = 0 if value.nan?
- 
 
       roll.push(value)
       if ( i >= aveLen)
@@ -65,19 +66,34 @@ def fetchRollingAve?(rrdPath, start, endTime, interval, myFunction, lIndex, retu
             final += rdata
          end
          final = (final / aveLen )
+
+         # Determine min / max to help with autoscale.
+         if ( final > my_max )
+            my_max = final
+         end
+         if ( final < my_min )
+            my_min = final
+         end
          returnList.append_data( StatsData.new(fstart + interval * ( i - indexOffset), final ))
  
          # Now shift the head off the array
          roll.shift
       end
    end
-   
+
+   # Now add the min / max to the lists
+   returnList.set_min_value(my_min)
+   returnList.set_max_value(my_max)
+
  return returnList
 end
 
 
 def fetchRollingCalcUsedData?(rrdPath, start, endTime, interval, myFunction, lIndex, returnList, aveLen=7)
 
+   my_min = 0
+   my_max = 0
+
    # OK, first thing we need to do is to move the start time back in order to have data to average.
       
    indexOffset = ( aveLen / 2 ).to_i
@@ -120,12 +136,24 @@ def fetchRollingCalcUsedData?(rrdPath, start, endTime, interval, myFunction, lIn
             final += rdata
          end
          final = (final / aveLen)
+
+         # Determine min / max to help with autoscale.
+         if ( final > my_max )
+            my_max = final
+         end
+         if ( final < my_min )
+            my_min = final
+         end
          returnList.append_data( StatsData.new(fstart + interval * ( i - indexOffset), final ))
          # Now shift the head off the array
          roll.shift
       end
    end
 
+   # Now add the min / max to the lists
+   returnList.set_min_value(my_min)
+   returnList.set_max_value(my_max)
+
  return returnList
 end
 
@@ -137,6 +165,9 @@ def fetchCalcUsedData?(rrdPath, start, endTime, interval, myFunction, lIndex, re
    #  We also need to handle NaN differently 
    #  Finally, we need to switch Min and Max
  
+   my_min = 0
+   my_max = 0
+
    lFunc = "AVERAGE"   
    case myFunction
       when "MAX"
@@ -155,13 +186,26 @@ def fetchCalcUsedData?(rrdPath, start, endTime, interval, myFunction, lIndex, re
    data.each do |vdata|
       i += 1
       value = vdata[lIndex]
-         value = 100 if value.nan?
-         if ( value > 100 )
-            value = 100
-         end
-         value  =  100 - value
+      value = 100 if value.nan?
+      if ( value > 100 )
+         value = 100
+      end
+      value  =  100 - value
+
+      # Determine min / max to help with autoscale.
+      if ( value > my_max )
+         my_max = value
+      end
+      if ( value < my_min )
+         my_min = value
+      end
+
       returnList.append_data( StatsData.new(fstart + interval * i, value ))
    end
+
+   # Now add the min / max to the lists
+   returnList.set_min_value(my_min)
+   returnList.set_max_value(my_max)
    
  return returnList
 end
@@ -169,6 +213,9 @@ end
 
 def fetchRegData?(rrdPath, start, endTime, interval, myFunction, lIndex, returnList)
 
+   my_min = 0
+   my_max = 0
+
    (fstart, fend, names, data, interval) = RRD.fetch(rrdPath, "--start", start.to_s, "--end", \
                                                endTime.to_s, myFunction, "-r", interval.to_s)
    i = 0 
@@ -177,9 +224,21 @@ def fetchRegData?(rrdPath, start, endTime, interval, myFunction, lIndex, returnL
 
    # Now, lets walk the returned data and create the ojects, and put them in a list.
    data.each do |vdata|
+      value = vdata[lIndex]
       i += 1
-      returnList.append_data( StatsData.new(fstart + interval * i, vdata[lIndex] ))
+      if ( value > my_max )
+         my_max = value
+      end
+      if ( value < my_min )
+         my_min = value
+      end
+
+      returnList.append_data( StatsData.new(fstart + interval * i, value ))
    end
+
+   # Now add the min / max to the lists
+   returnList.set_min_value(my_min)
+   returnList.set_max_value(my_max)
    
  return returnList
 end
@@ -294,7 +353,7 @@ def  getStatsData?(statRequestList)
        counter = request.get_counter?
        tmpList =fetchData?(request.get_node?, request.get_devClass?,request.get_instance?, request.get_counter?, \
                      request.get_starttime?, request.get_duration?,request.get_precision?, request.get_function?)
- 
+
        #  Now copy the array returned into the main array
        myList << tmpList
     end
diff --git a/wui/src/app/util/stats/StatsDataList.rb b/wui/src/app/util/stats/StatsDataList.rb
index d6de29c..0944cbc 100644
--- a/wui/src/app/util/stats/StatsDataList.rb
+++ b/wui/src/app/util/stats/StatsDataList.rb
@@ -21,7 +21,7 @@
 #define class StatsData  List
 class StatsDataList
   def initialize(node,devClass,instance, counter, status, function)
-    # Instance variables  
+    # Instance variables
     @node = node
     @devClass = devClass
     @instance = instance
@@ -29,41 +29,63 @@ class StatsDataList
     @data=[]
     @status = status
     @function = function
-  end  
+    @min_value = 0
+    @max_value = 0
+  end
   
-  def get_node?()  
+  def get_node?()
     return @node
-  end  
+  end
   
-  def get_devClass?()  
+  def get_node?()
+    return @node
+  end
+
+  def get_devClass?()
     return @devClass
-  end  
-  
-  def get_instance?()  
+  end
+
+  def get_instance?()
     return @instance
-  end  
-  
-  def get_counter?()  
+  end
+
+  def get_counter?()
     return @counter
-  end  
-  
-  def get_data?()  
+  end
+
+  def get_data?()
     return @data
-  end  
-  
-  def get_status?()  
+  end
+
+  def get_status?()
     return @status
-  end  
-  
-  def get_function?()  
+  end
+
+  def get_function?()
     return @function
-  end  
-  
-  def append_data(incoming)  
+  end
+
+  def append_data(incoming)
     @data << incoming
-  end  
-  
+  end
+
   def length()
     return @data.length
    end
-end  
+
+  def set_min_value(min)
+    @min_value = min
+  end
+
+  def set_max_value(max)
+    @max_value = max
+  end
+
+  def get_min_value?()
+    return @min_value
+  end
+
+  def get_max_value?()
+    return @max_value
+  end
+end
diff --git a/wui/src/app/util/stats/statsTest.rb b/wui/src/app/util/stats/statsTest.rb
index baedbc0..1da370c 100644
--- a/wui/src/app/util/stats/statsTest.rb
+++ b/wui/src/app/util/stats/statsTest.rb
@@ -33,11 +33,20 @@ require 'util/stats/Stats'
 #   requestList << StatsRequest.new("node3.priv.ovirt.org", DevClass::Load, 0, LoadCounter::Load_15min, 0, 0, RRDResolution::Long )
 #   requestList << StatsRequest.new("node7.priv.ovirt.org", DevClass::NIC, 0, NicCounter::Octets_rx, 0, 0, RRDResolution::Long )
 #   requestList << StatsRequest.new("node3.priv.ovirt.org", DevClass::NIC, 1, NicCounter::Octets_rx, 0, 0, RRDResolution::Long )
-   requestList << StatsRequest.new("node3.priv.ovirt.org", DevClass::NIC, 0, NicCounter::Octets_tx, 0, 604800, RRDResolution::Medium )
+#   requestList << StatsRequest.new("node5.priv.ovirt.org", DevClass::NIC, 0, NicCounter::Octets_tx, 0, 604800, RRDResolution::Long, DataFunction::Average )
+#   requestList << StatsRequest.new("node5.priv.ovirt.org", DevClass::NIC, 0, NicCounter::Octets_tx, 0, 604800, RRDResolution::Long, DataFunction::Peak )
+#   requestList << StatsRequest.new("node5.priv.ovirt.org", DevClass::NIC, 0, NicCounter::Octets_tx, 0, 604800, RRDResolution::Long)
 #   requestList << StatsRequest.new("node3.priv.ovirt.org", DevClass::Disk, 0, DiskCounter::Octets_read, 0, 0, RRDResolution::Long )
 #   requestList << StatsRequest.new("node3.priv.ovirt.org", DevClass::Disk, 0, DiskCounter::Octets_write, 0, 0, RRDResolution::Long )
 #   requestList << StatsRequest.new("node3.priv.ovirt.org", "cpu", 0, "idle", 1211688000, 3600, 10 )
-#   requestList << StatsRequest.new("node4.priv.ovirt.org", DevClass::CPU, 0, CpuCounter::Idle, 0, 3600, RRDResolution::Short )
+
+   requestList << StatsRequest.new("node3.priv.ovirt.org", DevClass::CPU, 0, CpuCounter::CalcUsed, 0, 300, RRDResolution::Default, DataFunction::Average )
+   requestList << StatsRequest.new("node3.priv.ovirt.org", DevClass::NIC, 0, NicCounter::Octets_rx, 0, 0, RRDResolution::Default )
+#   requestList << StatsRequest.new("node3.priv.ovirt.org", DevClass::CPU, 0, CpuCounter::Idle, 0, 300, RRDResolution::Default, DataFunction::RollingAverage )
+#   requestList << StatsRequest.new("node3.priv.ovirt.org", DevClass::CPU, 0, CpuCounter::Idle, 0, 300, RRDResolution::Default, DataFunction::Average )
+   requestList << StatsRequest.new("node3.priv.ovirt.org", DevClass::CPU, 0, CpuCounter::CalcUsed, 0, 300, RRDResolution::Default, DataFunction::RollingAverage )
+#   requestList << StatsRequest.new("node4.priv.ovirt.org", DevClass::CPU, 0, CpuCounter::Idle, 0, 3600, RRDResolution::Short, DataFunction::Average )
+#   requestList << StatsRequest.new("node4.priv.ovirt.org", DevClass::CPU, 0, CpuCounter::CalcUsed, 0, 3600, RRDResolution::Short, DataFunction::Min )
 #   requestList << StatsRequest.new("node5.priv.ovirt.org", "cpu", 0, "idle", 1211688000, 3600, 500 )
 #   requestList << StatsRequest.new("node5.priv.ovirt.org", DevClass::Memory, 0, MemCounter::Used, 0, 3600, 10 )
 
@@ -52,27 +61,28 @@ require 'util/stats/Stats'
 
 # puts statsListBig.length
    statsListBig.each do |statsList|
-   myNodeName = statsList.get_node?()
-   myDevClass = statsList.get_devClass?()
-   myInstance = statsList.get_instance?()
-   myCounter = statsList.get_counter?()
-   myStatus = statsList.get_status?()
+      myNodeName = statsList.get_node?()
+      myDevClass = statsList.get_devClass?()
+      myInstance = statsList.get_instance?()
+      myCounter = statsList.get_counter?()
+      myStatus = statsList.get_status?()
 
-   case myStatus
-      when StatsStatus::E_NOSUCHNODE
-          puts "Can't find data for node " + myNodeName
-      when StatsStatus::E_UNKNOWN
-          puts "Can't find data for requested file path"
-   end
-      if tmp != myNodeName then
+      case myStatus
+         when StatsStatus::E_NOSUCHNODE
+             puts "Can't find data for node " + myNodeName
+         when StatsStatus::E_UNKNOWN
+             puts "Can't find data for requested file path"
+      end
+         if tmp != myNodeName then
+            puts
+         end
+      list = statsList.get_data?()
+      list.each do |d|
+         print("\t", myNodeName, "\t", myDevClass, "\t", myInstance, "\t",  myCounter, "\t",d.get_value?, "\t",d.get_timestamp?)
          puts
       end
-   list = statsList.get_data?()
-   list.each do |d|
-      print("\t", myNodeName, "\t", myDevClass, "\t", myInstance, "\t",  myCounter, "\t",d.get_value?, "\t",d.get_timestamp?)
       puts
-   end  
       tmp = myNodeName
+      print("\tmin_value is: ", statsList.get_min_value?(), "\tmax_value is: ", statsList.get_max_value?())
+      puts
    end  
-
-
-- 
1.5.5.1



More information about the ovirt-devel mailing list