LGTM

On 10/19/2015 03:57 PM, 'Klaus Aehlig' via ganeti-devel wrote:
While the weights of the metric components cannot be changed easily
at run time, the specification for dynamic utilization is that they be
in arbitrary units. Therefore, simply scaling the utilization values
changes the weight of this measure. Note that it still makes sense to
have as a default measure the percentage of memory used.

Signed-off-by: Klaus Aehlig <[email protected]>
---
  src/Ganeti/HTools/Backend/MonD.hs | 18 ++++++++++++++++++
  1 file changed, 18 insertions(+)

diff --git a/src/Ganeti/HTools/Backend/MonD.hs 
b/src/Ganeti/HTools/Backend/MonD.hs
index ea1a31c..c6ccd37 100644
--- a/src/Ganeti/HTools/Backend/MonD.hs
+++ b/src/Ganeti/HTools/Backend/MonD.hs
@@ -49,6 +49,7 @@ module Ganeti.HTools.Backend.MonD
    , totalCPUCollector
    , xenCPUCollector
    , kvmRSSCollector
+  , scaleMemoryWeight
    ) where
import Control.Monad
@@ -249,6 +250,23 @@ kvmRSSCollector = DataCollector { dName = KvmRSS.dcName
                                  , dUse = useInstanceRSSData
                                  }
+-- | Scale the importance of the memory weight in dynamic utilisation,
+-- by multiplying the usage with the given factor. Note that the underlying
+-- model for dynamic utilisation is that they are reported in arbitrary units.
+scaleMemoryWeight :: Double
+                  -> (Node.List, Instance.List)
+                  -> (Node.List, Instance.List)
+scaleMemoryWeight f (nl, il) =
+  let updateInst inst =
+        let dynU = Instance.util inst
+            dynU' = dynU { memWeight = f * memWeight dynU}
+        in inst { Instance.util = dynU' }
+      updateNode node =
+        let dynU = Node.utilLoad node
+            dynU' = dynU { memWeight = f * memWeight dynU}
+        in node { Node.utilLoad = dynU' }
+  in (IntMap.map updateNode nl, IntMap.map updateInst il)
+
  -- * Collector choice
-- | The list of Data Collectors used by hail and hbal.

Reply via email to