From d3d112a2e4737a56c50b170896e3abdc0d1d2b1b Mon Sep 17 00:00:00 2001 From: Alex Marangone Date: Mon, 20 Apr 2020 13:43:45 -0700 Subject: [PATCH] restore 1f2df8db38b2a400758ef37ed2a531965ee120fe --- collectors/osd.go | 8 +++-- collectors/osd_test.go | 74 ++++++++++++++++++++++-------------------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/collectors/osd.go b/collectors/osd.go index 72aa16b..d479197 100644 --- a/collectors/osd.go +++ b/collectors/osd.go @@ -395,7 +395,7 @@ type cephOSDDF struct { } `json:"summary"` } -type cephOSDPerf struct { +type cephPerfStat struct { PerfInfo []struct { ID json.Number `json:"id"` Stats struct { @@ -405,6 +405,10 @@ type cephOSDPerf struct { } `json:"osd_perf_infos"` } +type CephOSDPerfStat struct { + cephPerfStat `json:"osdstats"` +} + type cephOSDDump struct { OSDs []struct { OSD json.Number `json:"osd"` @@ -583,7 +587,7 @@ func (o *OSDCollector) collectOSDPerf() error { return err } - osdPerf := &cephOSDPerf{} + osdPerf := &CephOSDPerfStat{} if err := json.Unmarshal(buf, osdPerf); err != nil { return err } diff --git a/collectors/osd_test.go b/collectors/osd_test.go index cb19fe9..561ed2d 100644 --- a/collectors/osd_test.go +++ b/collectors/osd_test.go @@ -164,43 +164,45 @@ func TestOSDCollector(t *testing.T) { cmdOut: map[string]string{ "ceph osd perf": ` { - "osd_perf_infos": [ - { - "id": 4, - "perf_stats": { - "commit_latency_ms": 0, - "apply_latency_ms": 0 + "osdstats": { + "osd_perf_infos": [ + { + "id": 4, + "perf_stats": { + "commit_latency_ms": 0, + "apply_latency_ms": 0 + } + }, + { + "id": 3, + "perf_stats": { + "commit_latency_ms": 1, + "apply_latency_ms": 64 + } + }, + { + "id": 2, + "perf_stats": { + "commit_latency_ms": 2, + "apply_latency_ms": 79 + } + }, + { + "id": 1, + "perf_stats": { + "commit_latency_ms": 2, + "apply_latency_ms": 39 + } + }, + { + "id": 0, + "perf_stats": { + "commit_latency_ms": 2, + "apply_latency_ms": 31 + } } - }, - { - "id": 3, - "perf_stats": { - "commit_latency_ms": 1, - "apply_latency_ms": 64 - } - }, - { - "id": 2, - "perf_stats": { - "commit_latency_ms": 2, - "apply_latency_ms": 79 - } - }, - { - "id": 1, - "perf_stats": { - "commit_latency_ms": 2, - "apply_latency_ms": 39 - } - }, - { - "id": 0, - "perf_stats": { - "commit_latency_ms": 2, - "apply_latency_ms": 31 - } - } - ] + ] + } }`, }, regexes: []*regexp.Regexp{