master
go 48 lines 1.63 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package powerstore
4
5 import "sync"
6
7 func (c *Collector) collectVolumes() {
8 var wg sync.WaitGroup
9
10 for id, vol := range c.discovered.volumes {
11 wg.Add(1)
12 go func(id, name string) {
13 defer wg.Done()
14 c.sem <- struct{}{}
15 defer func() { <-c.sem }()
16
17 pm, err := c.client.PerformanceMetricsByVolume(id)
18 if err != nil {
19 c.Warningf("error collecting volume %s perf metrics: %v", id, err)
20 } else if len(pm) > 0 {
21 last := pm[len(pm)-1]
22 c.mx.volume.perf.readIops.WithLabelValues(name).Observe(last.ReadIops)
23 c.mx.volume.perf.writeIops.WithLabelValues(name).Observe(last.WriteIops)
24 c.mx.volume.perf.readBandwidth.WithLabelValues(name).Observe(last.ReadBandwidth)
25 c.mx.volume.perf.writeBandwidth.WithLabelValues(name).Observe(last.WriteBandwidth)
26 c.mx.volume.perf.avgReadLatency.WithLabelValues(name).Observe(last.AvgReadLatency)
27 c.mx.volume.perf.avgWriteLatency.WithLabelValues(name).Observe(last.AvgWriteLatency)
28 c.mx.volume.perf.avgLatency.WithLabelValues(name).Observe(last.AvgLatency)
29 }
30
31 sm, err := c.client.SpaceMetricsByVolume(id)
32 if err != nil {
33 c.Warningf("error collecting volume %s space metrics: %v", id, err)
34 } else if len(sm) > 0 {
35 last := sm[len(sm)-1]
36 if last.LogicalProvisioned != nil {
37 c.mx.volume.spaceLogicalProv.WithLabelValues(name).Observe(float64(*last.LogicalProvisioned))
38 }
39 if last.LogicalUsed != nil {
40 c.mx.volume.spaceLogicalUsed.WithLabelValues(name).Observe(float64(*last.LogicalUsed))
41 }
42 c.mx.volume.spaceThinSavings.WithLabelValues(name).Observe(last.ThinSavings)
43 }
44 }(id, vol.Name)
45 }
46
47 wg.Wait()
48 }