Revision fca250e9

b/Ganeti/HTools/Cluster.hs
188 188
    let cs = foldl' updateCStats emptyCStats . Container.elems $ nl
189 189
    in cs { cs_score = compCV nl }
190 190

  
191
-- | The names of the individual elements in the CV list
192
detailedCVNames :: [String]
193
detailedCVNames = [ "free_mem_cv"
194
                  , "free_disk_cv"
195
                  , "n1_score"
196
                  , "reserved_mem_cv"
197
                  , "offline_score"
198
                  , "vcpu_ratio_cv"
199
                  ]
200

  
191 201
-- | Compute the mem and disk covariance.
192
compDetailedCV :: Node.List -> (Double, Double, Double, Double, Double, Double)
202
compDetailedCV :: Node.List -> [Double]
193 203
compDetailedCV nl =
194 204
    let
195 205
        all_nodes = Container.elems nl
......
213 223
                         fromIntegral (offline_inst + online_inst)::Double
214 224
        cpu_l = map Node.p_cpu nodes
215 225
        cpu_cv = varianceCoeff cpu_l
216
    in (mem_cv, dsk_cv, n1_score, res_cv, off_score, cpu_cv)
226
    in [mem_cv, dsk_cv, n1_score, res_cv, off_score, cpu_cv]
217 227

  
218 228
-- | Compute the /total/ variance.
219 229
compCV :: Node.List -> Double
220
compCV nl =
221
    let (mem_cv, dsk_cv, n1_score, res_cv, off_score, cpu_cv) =
222
            compDetailedCV nl
223
    in mem_cv + dsk_cv + n1_score + res_cv + off_score + cpu_cv
230
compCV = sum . compDetailedCV
224 231

  
225 232
-- | Compute online nodes from a Node.List
226 233
getOnline :: Node.List -> [Node.Node]
......
680 687
-- | Shows statistics for a given node list.
681 688
printStats :: Node.List -> String
682 689
printStats nl =
683
    let (mem_cv, dsk_cv, n1_score, res_cv, off_score, cpu_cv) =
684
            compDetailedCV nl
685
    in printf "f_mem=%.8f, r_mem=%.8f, f_dsk=%.8f, n1=%.3f, \
686
              \uf=%.3f, r_cpu=%.3f"
687
       mem_cv res_cv dsk_cv n1_score off_score cpu_cv
690
    let dcvs = compDetailedCV nl
691
        hd = zip (detailedCVNames ++ repeat "unknown") dcvs
692
        formatted = map (\(header, val) ->
693
                             printf "%s=%.8f" header val::String) hd
694
    in intercalate ", " formatted
688 695

  
689 696
-- | Convert a placement into a list of OpCodes (basically a job).
690 697
iMoveToJob :: String -> Node.List -> Instance.List

Also available in: Unified diff