-- | Query a node unless it is offline and return all
-- CPU reports. For offline nodes return the empty report.
queryNode :: Node.Node -> ResultT String IO AllReports
queryNode node = do
  let getReport dc = mkResultT
                     . liftM (maybe (Bad $ "Failed collecting "
                                           ++ MonD.dName dc
                                           ++ " from " ++ Node.name node) Ok
                              . MonD.mkReport dc)
                     $ MonD.fromCurl dc node
  if Node.offline node
    then return emptyReports
    else do
      total <- getReport MonD.totalCPUCollector
      xeninstances <- getReport MonD.xenCPUCollector
      return $ AllReports total xeninstances

-- | Get a map with the CPU live data for all nodes; for offline nodes
-- the empty report is guessed.
queryNode :: Node.Node -> ResultT String IO AllReports
queryNode node = do
  let getReport dc = mkResultT
                     . liftM (maybe (Bad $ "Failed collecting "
                                           ++ MonD.dName dc
                                           ++ " from " ++ Node.name node) Ok
                              . MonD.mkReport dc)
                     $ MonD.fromCurl dc node
  if Node.offline node
    then return emptyReports
    else do
      total <- getReport MonD.totalCPUCollector
      xeninstances <- getReport MonD.xenCPUCollector
      return $ AllReports total xeninstances

-- | Get a map with the CPU live data for all nodes; for offline nodes
-- the empty report is guessed.
queryNode node = do
  let getReport dc = mkResultT
                     . liftM (maybe (Bad $ "Failed collecting "
                                           ++ MonD.dName dc
                                           ++ " from " ++ Node.name node) Ok
                              . MonD.mkReport dc)
                     $ MonD.fromCurl dc node
  if Node.offline node
    then return emptyReports
    else do
      total <- getReport MonD.totalCPUCollector
      xeninstances <- getReport MonD.xenCPUCollector
      return $ AllReports total xeninstances

-- | Get a map with the CPU live data for all nodes; for offline nodes
-- the empty report is guessed.