Revision 82437b28

b/doc/design-monitoring-agent.rst
185 185
      There is no need of external intervention.
186 186

  
187 187
    ``2``
188
      The collector can determine that something is wrong and Ganeti has no
189
      way to fix it autonomously. External intervention is required.
190

  
191
    ``4``
192 188
      The collector has failed to understand whether the status is good or
193 189
      bad. Further analysis is required. Interpret this status as a
194 190
      potentially dangerous situation.
195 191

  
192
    ``4``
193
      The collector can determine that something is wrong and Ganeti has no
194
      way to fix it autonomously. External intervention is required.
195

  
196 196
  ``message``
197 197
    A message to better explain the reason of the status.
198 198
    The exact format of the message string is data collector dependent.
b/src/Ganeti/DataCollectors/Types.hs
26 26
-}
27 27

  
28 28
module Ganeti.DataCollectors.Types
29
  ( DCReport(..)
29
  ( addStatus
30 30
  , DCCategory(..)
31 31
  , DCKind(..)
32
  , DCReport(..)
33
  , DCStatus(..)
34
  , DCStatusCode(..)
32 35
  , DCVersion(..)
33 36
  , buildReport
34 37
  ) where
......
49 52
  readJSON =
50 53
    error "JSON read instance not implemented for type DCCategory"
51 54

  
55
-- | The possible status codes of a data collector.
56
data DCStatusCode = DCSCOk      -- ^ Everything is OK
57
                  | DCSCTempBad -- ^ Bad, but being automatically fixed
58
                  | DCSCUnknown -- ^ Unable to determine the status
59
                  | DCSCBad     -- ^ Bad. External intervention required
60
                  deriving (Show, Eq, Ord)
61

  
62
-- | The JSON instance for CollectorStatus.
63
instance JSON DCStatusCode where
64
  showJSON DCSCOk      = showJSON (0 :: Int)
65
  showJSON DCSCTempBad = showJSON (1 :: Int)
66
  showJSON DCSCUnknown = showJSON (2 :: Int)
67
  showJSON DCSCBad     = showJSON (4 :: Int)
68
  readJSON = error "JSON read instance not implemented for type DCStatusCode"
69

  
70
-- | The status of a \"status reporting data collector\".
71
$(buildObject "DCStatus" "dcStatus"
72
  [ simpleField "code"    [t| DCStatusCode |]
73
  , simpleField "message" [t| String |]
74
  ])
75

  
52 76
-- | The type representing the kind of the collector.
53 77
data DCKind = DCKPerf   -- ^ Performance reporting collector
54 78
            | DCKStatus -- ^ Status reporting collector
......
81 105
  , simpleField "data"           [t| JSValue |]
82 106
  ])
83 107

  
108
-- | Add the data collector status information to the JSON representation of
109
-- the collector data.
110
addStatus :: DCStatus -> JSValue -> JSValue
111
addStatus dcStatus (JSObject obj) =
112
  makeObj $ ("status", showJSON dcStatus) : fromJSObject obj
113
addStatus dcStatus value = makeObj
114
  [ ("status", showJSON dcStatus)
115
  , ("data", value)
116
  ]
117

  
84 118
-- | Utility function for building a report automatically adding the current
85 119
-- timestamp (rounded up to seconds).
86 120
-- If the version is not specified, it will be set to the value indicating

Also available in: Unified diff