From 7b120004edb0c15f559a943e2a27437684e45be0 Mon Sep 17 00:00:00 2001 From: Matt Vandersomething Date: Thu, 9 Sep 2021 14:16:37 -0300 Subject: [PATCH] collectors/health: fix snaptrim collection, add a test --- collectors/health.go | 4 ++++ collectors/health_test.go | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/collectors/health.go b/collectors/health.go index d50c30c..70c4e98 100644 --- a/collectors/health.go +++ b/collectors/health.go @@ -1296,6 +1296,10 @@ func (c *ClusterHealthCollector) collect(ch chan<- prometheus.Metric) error { if state == "scrubbing" { val -= *pgStateCounterMap["scrubbing+deep"] } + if state == "snaptrim" { + val -= *pgStateCounterMap["snaptrim_wait"] + } + gauge.Set(val) if state == "scrubbing+deep" { state = "deep_scrubbing" diff --git a/collectors/health_test.go b/collectors/health_test.go index 3505afd..6141429 100644 --- a/collectors/health_test.go +++ b/collectors/health_test.go @@ -333,6 +333,14 @@ $ sudo ceph -s { "state_name": "active+clean+inconsistent", "count": 1 + }, + { + "state_name": "active+clean+snaptrim", + "count": 15 + }, + { + "state_name": "active+clean+snaptrim_wait", + "count": 25 } ], "num_pgs": 52000 @@ -340,10 +348,12 @@ $ sudo ceph -s "health": {"summary": [{"severity": "HEALTH_WARN", "summary": "7 pgs undersized"}]} }`, regexes: []*regexp.Regexp{ - regexp.MustCompile(`active_pgs{cluster="ceph"} 8`), + regexp.MustCompile(`active_pgs{cluster="ceph"} 48`), regexp.MustCompile(`scrubbing_pgs{cluster="ceph"} 2`), regexp.MustCompile(`deep_scrubbing_pgs{cluster="ceph"} 5`), regexp.MustCompile(`inconsistent_pgs{cluster="ceph"} 1`), + regexp.MustCompile(`snaptrim_pgs{cluster="ceph"} 15`), + regexp.MustCompile(`snaptrim_wait_pgs{cluster="ceph"} 25`), }, }, {