Produce metrics for nominal output power.
This commit is contained in:
parent
2400f7fb14
commit
db1bca91ff
|
@ -31,6 +31,7 @@ type UPSCollector struct {
|
|||
LastTransferOnBattery *prometheus.Desc
|
||||
LastTransferOffBattery *prometheus.Desc
|
||||
LastSelftest *prometheus.Desc
|
||||
NominalPowerWatts *prometheus.Desc
|
||||
|
||||
ss StatusSource
|
||||
}
|
||||
|
@ -135,6 +136,13 @@ func NewUPSCollector(ss StatusSource) *UPSCollector {
|
|||
nil,
|
||||
),
|
||||
|
||||
NominalPowerWatts: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, "", "apcupsd_nominal_power_watts"),
|
||||
"Nominal power output in watts",
|
||||
labels,
|
||||
nil,
|
||||
),
|
||||
|
||||
ss: ss,
|
||||
}
|
||||
}
|
||||
|
@ -244,6 +252,13 @@ func (c *UPSCollector) collect(ch chan<- prometheus.Metric) (*prometheus.Desc, e
|
|||
labels...
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.NominalPowerWatts,
|
||||
prometheus.GaugeValue,
|
||||
float64(s.NominalPower),
|
||||
labels...,
|
||||
)
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ func TestUPSCollector(t *testing.T) {
|
|||
XOnBattery: time.Unix(100001, 0),
|
||||
XOffBattery: time.Unix(100002, 0),
|
||||
LastSelftest: time.Unix(100003, 0),
|
||||
NominalPower: 50.0,
|
||||
},
|
||||
},
|
||||
matches: []*regexp.Regexp{
|
||||
|
@ -61,6 +62,7 @@ func TestUPSCollector(t *testing.T) {
|
|||
regexp.MustCompile(`apcupsd_last_transfer_on_battery{hostname="a",model="b",ups_name="c"} 100001`),
|
||||
regexp.MustCompile(`apcupsd_last_transfer_off_battery{hostname="a",model="b",ups_name="c"} 100002`),
|
||||
regexp.MustCompile(`apcupsd_last_selftest{hostname="a",model="b",ups_name="c"} 100003`),
|
||||
regexp.MustCompile(`apcupsd_nominal_power_watts{hostname="a",model="b",ups_name="c"} 50`),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue