Skip to content

Commit de70e43

Browse files
authored
Merge pull request #151 from PureStorage-OpenConnect/150-fix-arrays_space_collectorgo-when-aspacesystem-=-nil-on-eg1-arrays
Fix arrays_space_collector.go when a.Space.System = nil on EG1 arrays
2 parents d9741f3 + c8ce743 commit de70e43

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

internal/openmetrics-exporter/arrays_space_collector.go

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,29 @@ func (c *ArraySpaceCollector) Collect(ch chan<- prometheus.Metric) {
134134
float64(*a.Space.TotalEffective), "total_effective",
135135
)
136136
}
137-
ch <- prometheus.MustNewConstMetric(
138-
c.SpaceDesc,
139-
prometheus.GaugeValue,
140-
a.Capacity-(float64(*a.Space.System)+float64(*a.Space.Replication)+float64(*a.Space.Shared)+float64(*a.Space.Snapshots)+float64(*a.Space.Unique)), "empty",
141-
)
142-
ch <- prometheus.MustNewConstMetric(
143-
c.UtilizationDesc,
144-
prometheus.GaugeValue,
145-
(float64(*a.Space.System)+float64(*a.Space.Replication)+float64(*a.Space.Shared)+float64(*a.Space.Snapshots)+float64(*a.Space.Unique))/a.Capacity*100,
146-
)
137+
if a.Space.System != nil {
138+
ch <- prometheus.MustNewConstMetric(
139+
c.SpaceDesc,
140+
prometheus.GaugeValue,
141+
a.Capacity-(float64(*a.Space.System)+float64(*a.Space.Replication)+float64(*a.Space.Shared)+float64(*a.Space.Snapshots)+float64(*a.Space.Unique)), "empty",
142+
)
143+
ch <- prometheus.MustNewConstMetric(
144+
c.UtilizationDesc,
145+
prometheus.GaugeValue,
146+
(float64(*a.Space.System)+float64(*a.Space.Replication)+float64(*a.Space.Shared)+float64(*a.Space.Snapshots)+float64(*a.Space.Unique))/a.Capacity*100,
147+
)
148+
} else {
149+
ch <- prometheus.MustNewConstMetric(
150+
c.SpaceDesc,
151+
prometheus.GaugeValue,
152+
a.Capacity-(float64(*a.Space.Replication)+float64(*a.Space.Shared)+float64(*a.Space.Snapshots)+float64(*a.Space.Unique)), "empty",
153+
)
154+
ch <- prometheus.MustNewConstMetric(
155+
c.UtilizationDesc,
156+
prometheus.GaugeValue,
157+
(float64(*a.Space.Replication)+float64(*a.Space.Shared)+float64(*a.Space.Snapshots)+float64(*a.Space.Unique))/a.Capacity*100,
158+
)
159+
}
147160
}
148161

149162
func NewArraySpaceCollector(fa *client.FAClient) *ArraySpaceCollector {

0 commit comments

Comments
 (0)