( main
, options
, arguments
+ , dcName
+ , dcVersion
+ , dcFormatVersion
+ , dcCategory
+ , dcKind
) where
import Ganeti.Types
import Ganeti.Utils
+
+-- | The name of this data collector.
+dcName :: String
+dcName = "inst-status-xen"
+
+-- | The version of this data collector.
+dcVersion :: DCVersion
+dcVersion = DCVerBuiltin
+
+-- | The version number for the data format of this data collector.
+dcFormatVersion :: Int
+dcFormatVersion = 1
+
+-- | The category of this data collector.
+dcCategory :: Maybe DCCategory
+dcCategory = Just DCInstance
+
+-- | The kind of this data collector.
+dcKind :: DCKind
+dcKind = DCKStatus
+
-- * Command line options
options :: IO [OptType]
trail
status
--- | Main function.
-main :: Options -> [String] -> IO ()
-main opts _ = do
- curNode <- getHostName
- let node = fromMaybe curNode $ optNode opts
- answer <- getInstances node (optConfdAddr opts) (optConfdPort opts)
+-- | Build the report of this data collector, containing all the information
+-- about the status of the instances.
+buildInstStatusReport :: Maybe String -> Maybe Int -> IO DCReport
+buildInstStatusReport srvAddr srvPort = do
+ node <- getHostName
+ answer <- getInstances node srvAddr srvPort
inst <- exitIfBad "Can't get instance info from ConfD" answer
domains <- getInferredDomInfo
uptimes <- getUptimeInfo
let primaryInst = fst inst
iStatus <- mapM (buildStatus domains uptimes) primaryInst
- putStrLn $ J.encode iStatus
+ let jsonReport = J.showJSON iStatus
+ buildReport dcName dcVersion dcFormatVersion dcCategory dcKind jsonReport
+
+-- | Main function.
+main :: Options -> [String] -> IO ()
+main opts _ = do
+ report <- buildInstStatusReport (optConfdAddr opts) (optConfdPort opts)
+ putStrLn $ J.encode report