Skip to content

Commit 358c3e3

Browse files
Update arrays_controllers_collector.go
1 parent 95c532b commit 358c3e3

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

internal/openmetrics-exporter/arrays_controllers_collector.go

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import (
77
)
88

99
type ControllersCollector struct {
10-
ControllersDesc *prometheus.Desc
11-
Client *client.FAClient
10+
ControllersModeSinceDesc *prometheus.Desc
11+
ControllersInfoDesc *prometheus.Desc
12+
Client *client.FAClient
1213
}
1314

1415
func (c *ControllersCollector) Describe(ch chan<- *prometheus.Desc) {
@@ -20,22 +21,37 @@ func (c *ControllersCollector) Collect(ch chan<- prometheus.Metric) {
2021
if len(cl.Items) == 0 {
2122
return
2223
}
23-
for _, d := range cl.Items {
24+
for _, ctl := range cl.Items {
25+
if ctl.ModeSince != 0 {
26+
ch <- prometheus.MustNewConstMetric(
27+
c.ControllersModeSinceDesc,
28+
prometheus.GaugeValue,
29+
// OpenMetrics timestamps MUST be in seconds, divide as an float64 to keep precision
30+
(float64(ctl.ModeSince) / 1000),
31+
ctl.Mode, ctl.Model, ctl.Name, ctl.Status, ctl.Type, ctl.Version,
32+
)
33+
}
2434
ch <- prometheus.MustNewConstMetric(
25-
c.ControllersDesc,
35+
c.ControllersInfoDesc,
2636
prometheus.GaugeValue,
27-
// OpenMetrics timestamps MUST be in seconds, divide as an float64 to keep precision
28-
(float64(d.ModeSince) / 1000),
29-
d.Mode, d.Model, d.Name, d.Status, d.Type, d.Version,
37+
1,
38+
ctl.Mode, ctl.Model, ctl.Name, ctl.Status, ctl.Type, ctl.Version,
3039
)
40+
3141
}
3242
}
3343

3444
func NewControllersCollector(fa *client.FAClient) *ControllersCollector {
3545
return &ControllersCollector{
36-
ControllersDesc: prometheus.NewDesc(
46+
ControllersModeSinceDesc: prometheus.NewDesc(
3747
"purefa_hw_controller_mode_since_timestamp_seconds",
38-
"FlashArray controller mode since",
48+
"FlashArray controller mode since status change timestamp in seconds since UNIX epoch",
49+
[]string{"mode", "model", "name", "status", "type", "version"},
50+
prometheus.Labels{},
51+
),
52+
ControllersInfoDesc: prometheus.NewDesc(
53+
"purefa_hw_controller_info",
54+
"FlashArray controller info",
3955
[]string{"mode", "model", "name", "status", "type", "version"},
4056
prometheus.Labels{},
4157
),

0 commit comments

Comments
 (0)