If we don't find an instance in the output of xentop any more that usually means it moved away. In this case, it might be useful to still have the old CPU load as a best guess until a new value is available on the new location. But after this period, we should stop reporting usage information for that instance.
Signed-off-by: Klaus Aehlig <[email protected]> --- src/Ganeti/DataCollectors/XenCpuLoad.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Ganeti/DataCollectors/XenCpuLoad.hs b/src/Ganeti/DataCollectors/XenCpuLoad.hs index 897512d..2a66513 100644 --- a/src/Ganeti/DataCollectors/XenCpuLoad.hs +++ b/src/Ganeti/DataCollectors/XenCpuLoad.hs @@ -42,7 +42,7 @@ module Ganeti.DataCollectors.XenCpuLoad , dcUpdate ) where -import Control.Applicative ((<$>)) +import Control.Applicative ((<$>), liftA2) import Control.Arrow ((***)) import Control.Monad (liftM, when) import Control.Monad.IO.Class (liftIO) @@ -141,7 +141,13 @@ dcUpdate maybeCollector = do . (clockTimeToUSec now -) . clockTimeToUSec . fst)) combinedValues - return $ InstanceCpuLoad withinRange + withoutOld = Map.filter + (liftA2 (&&) (not . Seq.null) + $ (>) (fromIntegral $ C.xentopAverageThreshold * 1000000) + . (clockTimeToUSec now -) . clockTimeToUSec + . fst . flip Seq.index 0) + withinRange + return $ InstanceCpuLoad withoutOld -- | From a list of timestamps and cumulative CPU data, compute the -- average CPU activity in vCPUs. -- 2.2.0.rc0.207.ga3a616c
