41 |
41 |
import Ganeti.Common
|
42 |
42 |
import Ganeti.DataCollectors.CLI
|
43 |
43 |
import Ganeti.DataCollectors.InstStatusTypes
|
|
44 |
import Ganeti.DataCollectors.Types
|
44 |
45 |
import Ganeti.Hypervisor.Xen
|
45 |
46 |
import Ganeti.Hypervisor.Xen.Types
|
46 |
47 |
import Ganeti.Objects
|
... | ... | |
78 |
79 |
Just (J.Error msg) -> BT.Bad msg
|
79 |
80 |
Nothing -> BT.Bad "No answer from the Confd server"
|
80 |
81 |
|
|
82 |
-- | Determine the value of the status field for the report of one instance
|
|
83 |
computeStatusField :: AdminState -> ActualState -> DCStatus
|
|
84 |
computeStatusField AdminDown actualState =
|
|
85 |
if actualState `notElem` [ActualShutdown, ActualDying]
|
|
86 |
then DCStatus DCSCBad "The instance is not stopped as it should be"
|
|
87 |
else DCStatus DCSCOk ""
|
|
88 |
computeStatusField AdminUp ActualHung =
|
|
89 |
DCStatus DCSCUnknown "Instance marked as running, but it appears to be hung"
|
|
90 |
computeStatusField AdminUp actualState =
|
|
91 |
if actualState `notElem` [ActualRunning, ActualBlocked]
|
|
92 |
then DCStatus DCSCBad "The instance is not running as it should be"
|
|
93 |
else DCStatus DCSCOk ""
|
|
94 |
computeStatusField AdminOffline _ =
|
|
95 |
-- FIXME: The "offline" status seems not to be used anywhere in the source
|
|
96 |
-- code, but it is defined, so we have to consider it anyway here.
|
|
97 |
DCStatus DCSCUnknown "The instance is marked as offline"
|
|
98 |
|
81 |
99 |
-- Builds the status of an instance using runtime information about the Xen
|
82 |
100 |
-- Domains, their uptime information and the static information provided by
|
83 |
101 |
-- the ConfD server.
|
... | ... | |
99 |
117 |
then ActualHung
|
100 |
118 |
else domState dom
|
101 |
119 |
_ -> ActualUnknown
|
|
120 |
status = computeStatusField adminState actualState
|
102 |
121 |
return $
|
103 |
122 |
InstStatus
|
104 |
123 |
name
|
... | ... | |
107 |
126 |
actualState
|
108 |
127 |
uptime
|
109 |
128 |
(instMtime inst)
|
|
129 |
status
|
110 |
130 |
|
111 |
131 |
-- | Main function.
|
112 |
132 |
main :: Options -> [String] -> IO ()
|