Revision 4fe04580

b/src/Ganeti/DataCollectors/InstStatus.hs
179 179
      trail
180 180
      status
181 181

  
182
-- | Main function.
183
main :: Options -> [String] -> IO ()
184
main opts _ = do
185
  curNode <- getHostName
186
  let node = fromMaybe curNode $ optNode opts
187
  answer <- getInstances node (optConfdAddr opts) (optConfdPort opts)
182
-- | Build the report of this data collector, containing all the information
183
-- about the status of the instances.
184
buildInstStatusReport :: Maybe String -> Maybe Int -> IO DCReport
185
buildInstStatusReport srvAddr srvPort = do
186
  node <- getHostName
187
  answer <- getInstances node srvAddr srvPort
188 188
  inst <- exitIfBad "Can't get instance info from ConfD" answer
189 189
  domains <- getInferredDomInfo
190 190
  uptimes <- getUptimeInfo
191 191
  let primaryInst =  fst inst
192 192
  iStatus <- mapM (buildStatus domains uptimes) primaryInst
193
  putStrLn $ J.encode iStatus
193
  let jsonReport = J.showJSON iStatus
194
  buildReport dcName dcVersion dcFormatVersion dcCategory dcKind jsonReport
195

  
196
-- | Main function.
197
main :: Options -> [String] -> IO ()
198
main opts _ = do
199
  report <- buildInstStatusReport (optConfdAddr opts) (optConfdPort opts)
200
  putStrLn $ J.encode report

Also available in: Unified diff