@@ -74,7 +74,17 @@ type CephStatus struct {
7474}
7575
7676type HealthStatus struct {
77- Status string `json:"status"`
77+ Status string `json:"status"`
78+ Checks map [string ]CheckMessage `json:"checks"`
79+ }
80+
81+ type CheckMessage struct {
82+ Severity string `json:"severity"`
83+ Summary Summary `json:"summary"`
84+ }
85+
86+ type Summary struct {
87+ Message string `json:"message"`
7888}
7989
8090type OsdMap struct {
@@ -121,6 +131,7 @@ func cephStatus(analyzer *troubleshootv1beta2.CephStatusAnalyze, getCollectedFil
121131 if outcome .Fail .When == "" {
122132 outcome .Fail .When = string (CephHealthErr )
123133 }
134+
124135 match , err := compareCephStatus (status .Health .Status , outcome .Fail .When )
125136 if err != nil {
126137 return nil , errors .Wrap (err , "failed to compare ceph status" )
@@ -134,6 +145,7 @@ func cephStatus(analyzer *troubleshootv1beta2.CephStatusAnalyze, getCollectedFil
134145 if outcome .Warn .When == "" {
135146 outcome .Warn .When = string (CephHealthWarn )
136147 }
148+
137149 match , err := compareCephStatus (status .Health .Status , outcome .Warn .When )
138150 if err != nil {
139151 return nil , errors .Wrap (err , "failed to compare ceph status" )
@@ -147,13 +159,15 @@ func cephStatus(analyzer *troubleshootv1beta2.CephStatusAnalyze, getCollectedFil
147159 if outcome .Pass .When == "" {
148160 outcome .Pass .When = string (CephHealthOK )
149161 }
162+
150163 match , err := compareCephStatus (status .Health .Status , outcome .Pass .When )
151164 if err != nil {
152165 return nil , errors .Wrap (err , "failed to compare ceph status" )
153166 } else if match {
154167 analyzeResult .IsPass = true
155168 analyzeResult .Message = outcome .Pass .Message
156169 analyzeResult .URI = outcome .Pass .URI
170+
157171 return analyzeResult , nil
158172 }
159173 }
@@ -195,21 +209,33 @@ func compareCephStatus(actual, when string) (bool, error) {
195209 }
196210}
197211
198- func detailedCephMessage (msg string , status CephStatus ) string {
212+ func detailedCephMessage (outcomeMessage string , status CephStatus ) string {
213+ var msg = []string {}
214+
215+ if outcomeMessage != "" {
216+ msg = append (msg , outcomeMessage )
217+ }
218+
199219 if status .OsdMap .OsdMap .NumOsd > 0 {
200- msg = fmt .Sprintf ("%s. % v/%v OSDs up" , msg , status .OsdMap .OsdMap .NumUpOsd , status .OsdMap .OsdMap .NumOsd )
220+ msg = append ( msg , fmt .Sprintf ("%v/%v OSDs up" , status .OsdMap .OsdMap .NumUpOsd , status .OsdMap .OsdMap .NumOsd ) )
201221 }
202222
203223 if status .OsdMap .OsdMap .Full {
204- msg = fmt .Sprintf ("%s. OSD disk is full" , msg )
224+ msg = append ( msg , fmt .Sprintf ("OSD disk is full" ) )
205225 } else if status .OsdMap .OsdMap .NearFull {
206- msg = fmt .Sprintf ("%s. OSD disk is nearly full" , msg )
226+ msg = append ( msg , fmt .Sprintf ("OSD disk is nearly full" ) )
207227 }
208228
209229 if status .PgMap .TotalBytes > 0 {
210230 pgUsage := 100 * float64 (status .PgMap .UsedBytes ) / float64 (status .PgMap .TotalBytes )
211- msg = fmt .Sprintf ("%s. PG storage usage is %.1f%%." , msg , pgUsage )
231+ msg = append (msg , fmt .Sprintf ("PG storage usage is %.1f%%." , pgUsage ))
232+ }
233+
234+ if status .Health .Checks != nil {
235+ for k , v := range status .Health .Checks {
236+ msg = append (msg , fmt .Sprintf ("%s: %s" , k , v .Summary .Message ))
237+ }
212238 }
213239
214- return msg
240+ return strings . Join ( msg , " \n " )
215241}
0 commit comments