| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package powerstore |
| 4 | |
| 5 | import "sync" |
| 6 | |
| 7 | func (c *Collector) collectAppliances() { |
| 8 | var wg sync.WaitGroup |
| 9 | |
| 10 | for id, app := range c.discovered.appliances { |
| 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.PerformanceMetricsByAppliance(id) |
| 18 | if err != nil { |
| 19 | c.Warningf("error collecting appliance %s perf metrics: %v", id, err) |
| 20 | } else if len(pm) > 0 { |
| 21 | last := pm[len(pm)-1] |
| 22 | c.mx.appliance.perf.readIops.WithLabelValues(name).Observe(last.ReadIops) |
| 23 | c.mx.appliance.perf.writeIops.WithLabelValues(name).Observe(last.WriteIops) |
| 24 | c.mx.appliance.perf.readBandwidth.WithLabelValues(name).Observe(last.ReadBandwidth) |
| 25 | c.mx.appliance.perf.writeBandwidth.WithLabelValues(name).Observe(last.WriteBandwidth) |
| 26 | c.mx.appliance.perf.avgReadLatency.WithLabelValues(name).Observe(last.AvgReadLatency) |
| 27 | c.mx.appliance.perf.avgWriteLatency.WithLabelValues(name).Observe(last.AvgWriteLatency) |
| 28 | c.mx.appliance.perf.avgLatency.WithLabelValues(name).Observe(last.AvgLatency) |
| 29 | c.mx.appliance.cpu.WithLabelValues(name).Observe(last.IoWorkloadCPUUtilization) |
| 30 | } |
| 31 | |
| 32 | sm, err := c.client.SpaceMetricsByAppliance(id) |
| 33 | if err != nil { |
| 34 | c.Warningf("error collecting appliance %s space metrics: %v", id, err) |
| 35 | } else if len(sm) > 0 { |
| 36 | last := sm[len(sm)-1] |
| 37 | if last.PhysicalTotal != nil { |
| 38 | c.mx.appliance.space.physicalTotal.WithLabelValues(name).Observe(float64(*last.PhysicalTotal)) |
| 39 | } |
| 40 | if last.PhysicalUsed != nil { |
| 41 | c.mx.appliance.space.physicalUsed.WithLabelValues(name).Observe(float64(*last.PhysicalUsed)) |
| 42 | } |
| 43 | if last.LogicalProvisioned != nil { |
| 44 | c.mx.appliance.space.logicalProvisioned.WithLabelValues(name).Observe(float64(*last.LogicalProvisioned)) |
| 45 | } |
| 46 | if last.LogicalUsed != nil { |
| 47 | c.mx.appliance.space.logicalUsed.WithLabelValues(name).Observe(float64(*last.LogicalUsed)) |
| 48 | } |
| 49 | if last.DataPhysicalUsed != nil { |
| 50 | c.mx.appliance.space.dataPhysicalUsed.WithLabelValues(name).Observe(float64(*last.DataPhysicalUsed)) |
| 51 | } |
| 52 | if last.SharedLogicalUsed != nil { |
| 53 | c.mx.appliance.space.sharedLogicalUsed.WithLabelValues(name).Observe(float64(*last.SharedLogicalUsed)) |
| 54 | } |
| 55 | c.mx.appliance.space.efficiencyRatio.WithLabelValues(name).Observe(last.EfficiencyRatio) |
| 56 | c.mx.appliance.space.dataReduction.WithLabelValues(name).Observe(last.DataReduction) |
| 57 | c.mx.appliance.space.snapshotSavings.WithLabelValues(name).Observe(last.SnapshotSavings) |
| 58 | c.mx.appliance.space.thinSavings.WithLabelValues(name).Observe(last.ThinSavings) |
| 59 | } |
| 60 | }(id, app.Name) |
| 61 | } |
| 62 | |
| 63 | wg.Wait() |
| 64 | } |