Revision 79731e21 src/Ganeti/DataCollectors/InstStatus.hs
b/src/Ganeti/DataCollectors/InstStatus.hs | ||
---|---|---|
36 | 36 |
|
37 | 37 |
|
38 | 38 |
import Control.Exception.Base |
39 |
import Data.List |
|
39 | 40 |
import Data.Maybe |
40 | 41 |
import qualified Data.Map as Map |
41 | 42 |
import Network.BSD (getHostName) |
... | ... | |
179 | 180 |
trail |
180 | 181 |
status |
181 | 182 |
|
183 |
-- | Compute the status code and message, given the current DRBD data |
|
184 |
-- The final state will have the code corresponding to the worst code of |
|
185 |
-- all the devices, and the error message given from the concatenation of the |
|
186 |
-- non-empty error messages. |
|
187 |
computeGlobalStatus :: [InstStatus] -> DCStatus |
|
188 |
computeGlobalStatus instStatusList = |
|
189 |
let dcstatuses = map iStatStatus instStatusList |
|
190 |
statuses = map (\s -> (dcStatusCode s, dcStatusMessage s)) dcstatuses |
|
191 |
(code, strList) = foldr mergeStatuses (DCSCOk, [""]) statuses |
|
192 |
in DCStatus code $ intercalate "\n" strList |
|
193 |
|
|
182 | 194 |
-- | Build the report of this data collector, containing all the information |
183 | 195 |
-- about the status of the instances. |
184 | 196 |
buildInstStatusReport :: Maybe String -> Maybe Int -> IO DCReport |
... | ... | |
190 | 202 |
uptimes <- getUptimeInfo |
191 | 203 |
let primaryInst = fst inst |
192 | 204 |
iStatus <- mapM (buildStatus domains uptimes) primaryInst |
193 |
let jsonReport = J.showJSON iStatus |
|
205 |
let globalStatus = computeGlobalStatus iStatus |
|
206 |
jsonReport = J.showJSON $ ReportData iStatus globalStatus |
|
194 | 207 |
buildReport dcName dcVersion dcFormatVersion dcCategory dcKind jsonReport |
195 | 208 |
|
196 | 209 |
-- | Main function. |
Also available in: Unified diff