Add ceph_health metrics to ceph input (#5482)
This commit is contained in:
@@ -319,6 +319,10 @@ func (c *Ceph) exec(command string) (string, error) {
|
||||
|
||||
// CephStatus is used to unmarshal "ceph -s" output
|
||||
type CephStatus struct {
|
||||
Health struct {
|
||||
Status string `json:"status"`
|
||||
OverallStatus string `json:"overall_status"`
|
||||
} `json:"health"`
|
||||
OSDMap struct {
|
||||
OSDMap struct {
|
||||
Epoch float64 `json:"epoch"`
|
||||
@@ -357,6 +361,7 @@ func decodeStatus(acc telegraf.Accumulator, input string) error {
|
||||
}
|
||||
|
||||
decoders := []func(telegraf.Accumulator, *CephStatus) error{
|
||||
decodeStatusHealth,
|
||||
decodeStatusOsdmap,
|
||||
decodeStatusPgmap,
|
||||
decodeStatusPgmapState,
|
||||
@@ -371,6 +376,16 @@ func decodeStatus(acc telegraf.Accumulator, input string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// decodeStatusHealth decodes the health portion of the output of 'ceph status'
|
||||
func decodeStatusHealth(acc telegraf.Accumulator, data *CephStatus) error {
|
||||
fields := map[string]interface{}{
|
||||
"status": data.Health.Status,
|
||||
"overall_status": data.Health.OverallStatus,
|
||||
}
|
||||
acc.AddFields("ceph_health", fields, map[string]string{})
|
||||
return nil
|
||||
}
|
||||
|
||||
// decodeStatusOsdmap decodes the OSD map portion of the output of 'ceph -s'
|
||||
func decodeStatusOsdmap(acc telegraf.Accumulator, data *CephStatus) error {
|
||||
fields := map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user