Revision 19777638

b/Ganeti/HTools/Cluster.hs
646 646
    in unlines $ (header:map (uncurry helper) snl')
647 647

  
648 648
-- | Compute the mem and disk covariance.
649
compDetailedCV :: NodeList -> (Double, Double, Double, Double)
649
compDetailedCV :: NodeList -> (Double, Double, Double, Double, Double)
650 650
compDetailedCV nl =
651 651
    let
652
        nodes = Container.elems nl
652
        all_nodes = Container.elems nl
653
        (offline, nodes) = partition Node.offline all_nodes
653 654
        mem_l = map Node.p_mem nodes
654 655
        dsk_l = map Node.p_dsk nodes
655 656
        mem_cv = varianceCoeff mem_l
......
658 659
        n1_score = (fromIntegral n1_l) / (fromIntegral $ length nodes)
659 660
        res_l = map Node.p_rem nodes
660 661
        res_cv = varianceCoeff res_l
661
    in (mem_cv, dsk_cv, n1_score, res_cv)
662
        offline_inst = sum . map (\n -> (length . Node.plist $ n) +
663
                                        (length . Node.slist $ n)) $ offline
664
        online_inst = sum . map (\n -> (length . Node.plist $ n) +
665
                                       (length . Node.slist $ n)) $ nodes
666
        off_score = (fromIntegral offline_inst) /
667
                    (fromIntegral $ online_inst + offline_inst)
668
    in (mem_cv, dsk_cv, n1_score, res_cv, off_score)
662 669

  
663 670
-- | Compute the 'total' variance.
664 671
compCV :: NodeList -> Double
665 672
compCV nl =
666
    let (mem_cv, dsk_cv, n1_score, res_cv) = compDetailedCV nl
667
    in mem_cv + dsk_cv + n1_score + res_cv
673
    let (mem_cv, dsk_cv, n1_score, res_cv, off_score) = compDetailedCV nl
674
    in mem_cv + dsk_cv + n1_score + res_cv + off_score
668 675

  
669 676
printStats :: NodeList -> String
670 677
printStats nl =
671
    let (mem_cv, dsk_cv, n1_score, res_cv) = compDetailedCV nl
672
    in printf "f_mem=%.8f, r_mem=%.8f, f_dsk=%.8f, n1=%.3f"
673
       mem_cv res_cv dsk_cv n1_score
678
    let (mem_cv, dsk_cv, n1_score, res_cv, off_score) = compDetailedCV nl
679
    in printf "f_mem=%.8f, r_mem=%.8f, f_dsk=%.8f, n1=%.3f, uf=%.3f"
680
       mem_cv res_cv dsk_cv n1_score off_score
674 681

  
675 682
-- Balancing functions
676 683

  

Also available in: Unified diff