diff --git a/collectors/health.go b/collectors/health.go index eac0445..c9fb568 100644 --- a/collectors/health.go +++ b/collectors/health.go @@ -33,8 +33,8 @@ var ( recoveryIOObjectsRegex = regexp.MustCompile(`(\d+) objects/s`) clientReadBytesPerSecRegex = regexp.MustCompile(`(\d+) ([kKmMgG][bB])/s rd`) clientWriteBytesPerSecRegex = regexp.MustCompile(`(\d+) ([kKmMgG][bB])/s wr`) - ClientIOReadOpsRegex = regexp.MustCompile(`(\d+) op/s rd`) - ClientIOWriteOpsRegex = regexp.MustCompile(`(\d+) op/s wr`) + clientIOReadOpsRegex = regexp.MustCompile(`(\d+) op/s rd`) + clientIOWriteOpsRegex = regexp.MustCompile(`(\d+) op/s wr`) cacheFlushRateRegex = regexp.MustCompile(`(\d+) ([kKmMgG][bB])/s flush`) cacheEvictRateRegex = regexp.MustCompile(`(\d+) ([kKmMgG][bB])/s evict`) cachePromoteOpsRegex = regexp.MustCompile(`(\d+) op/s promote`) @@ -490,6 +490,7 @@ type cephHealthStats struct { Summary string `json:"summary"` } `json:"summary"` OverallStatus string `json:"overall_status"` + Status string `json:"status"` Checks map[string]struct { Severity string `json:"severity"` Summary struct { @@ -555,6 +556,17 @@ func (c *ClusterHealthCollector) collect() error { c.HealthStatus.Set(2) } + // This will be set only if Luminous is running. Will be + // ignored otherwise. + switch stats.Health.Status { + case CephHealthOK: + c.HealthStatus.Set(0) + case CephHealthWarn: + c.HealthStatus.Set(1) + case CephHealthErr: + c.HealthStatus.Set(2) + } + var ( degradedRegex = regexp.MustCompile(`([\d]+) pgs degraded`) stuckDegradedRegex = regexp.MustCompile(`([\d]+) pgs stuck degraded`) @@ -887,7 +899,7 @@ func (c *ClusterHealthCollector) collectClientIO(clientStr string) error { } var ClientIOReadOps, ClientIOWriteOps float64 - matched = ClientIOReadOpsRegex.FindStringSubmatch(clientStr) + matched = clientIOReadOpsRegex.FindStringSubmatch(clientStr) if len(matched) == 2 { v, err := strconv.Atoi(matched[1]) if err != nil { @@ -898,7 +910,7 @@ func (c *ClusterHealthCollector) collectClientIO(clientStr string) error { c.ClientIOReadOps.Set(ClientIOReadOps) } - matched = ClientIOWriteOpsRegex.FindStringSubmatch(clientStr) + matched = clientIOWriteOpsRegex.FindStringSubmatch(clientStr) if len(matched) == 2 { v, err := strconv.Atoi(matched[1]) if err != nil { diff --git a/collectors/health_test.go b/collectors/health_test.go index a92c73d..1fb5fb6 100644 --- a/collectors/health_test.go +++ b/collectors/health_test.go @@ -253,6 +253,38 @@ func TestClusterHealthCollector(t *testing.T) { }, { input: ` +{ + "osdmap": { + "osdmap": { + "num_osds": 1200, + "num_up_osds": 1200, + "num_in_osds": 1190, + "num_remapped_pgs": 10 + } + }, + "health": { "overall_status": "HEALTH_WARN", "status": "HEALTH_OK } }`, + regexes: []*regexp.Regexp{ + regexp.MustCompile(`health_status{cluster="ceph"} 0`), + }, + }, + { + input: ` +{ + "osdmap": { + "osdmap": { + "num_osds": 1200, + "num_up_osds": 1200, + "num_in_osds": 1190, + "num_remapped_pgs": 10 + } + }, + "health": { "status": "HEALTH_OK } }`, + regexes: []*regexp.Regexp{ + regexp.MustCompile(`health_status{cluster="ceph"} 0`), + }, + }, + { + input: ` { "osdmap": { "osdmap": {