diff --git a/hspace.hs b/hspace.hs index bb4b715ac2edbf3c0ab4420b85839cdeb5cb124a..058d30f741ba6e0d434569beda885fa54c9e9683 100644 --- a/hspace.hs +++ b/hspace.hs @@ -114,6 +114,7 @@ clusterData :: [(String, Cluster.CStats -> String)] clusterData = [ ("MEM", printf "%.0f" . Cluster.csTmem) , ("DSK", printf "%.0f" . Cluster.csTdsk) , ("CPU", printf "%.0f" . Cluster.csTcpu) + , ("VCPU", printf "%d" . Cluster.csVcpu) ] -- | Recursively place instances on the cluster until we're out of space @@ -189,6 +190,22 @@ printResults fin_nl num_instances allocs sreason = do -- this should be the final entry printKeys [("OK", "1")] +formatRSpec :: String -> RSpec -> [(String, String)] +formatRSpec s r = + [ ("KM_" ++ s ++ "_CPU", show $ rspecCpu r) + , ("KM_" ++ s ++ "_MEM", show $ rspecMem r) + , ("KM_" ++ s ++ "_DSK", show $ rspecDsk r) + ] + +printAllocationStats :: Node.List -> Node.List -> IO () +printAllocationStats ini_nl fin_nl = do + let ini_stats = Cluster.totalResources ini_nl + fin_stats = Cluster.totalResources fin_nl + (rini, ralo, runa) = Cluster.computeAllocationDelta ini_stats fin_stats + printKeys $ formatRSpec "USED" rini + printKeys $ formatRSpec "POOL" ralo + printKeys $ formatRSpec "UNAV" runa + -- | Ensure a value is quoted if needed ensureQuoted :: String -> String ensureQuoted v = if not (all (\c -> (isAlphaNum c || c == '.')) v) @@ -325,7 +342,8 @@ main = do hPutStrLn stderr $ Cluster.printNodes trl_nl (fromJust shownodes) printKeys $ printStats PTiered (Cluster.totalResources trl_nl) - printKeys [("TSPEC", intercalate " " spec_map')]) + printKeys [("TSPEC", intercalate " " spec_map')] + printAllocationStats nl trl_nl) -- Run the standard (avg-mode) allocation