mirror of
https://github.com/mdlayher/apcupsd_exporter.git
synced 2024-11-24 11:15:17 +01:00
apcupsd_exporter: add UPS status label to info metric
Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
parent
420d526dee
commit
3f531e59fc
@ -50,7 +50,7 @@ func NewUPSCollector(ss StatusSource) *UPSCollector {
|
||||
Info: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(namespace, "", "info"),
|
||||
"Metadata about a given UPS.",
|
||||
[]string{"ups", "hostname", "model"},
|
||||
[]string{"ups", "hostname", "model", "status"},
|
||||
nil,
|
||||
),
|
||||
|
||||
@ -212,7 +212,7 @@ func (c *UPSCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
c.Info,
|
||||
prometheus.GaugeValue,
|
||||
1,
|
||||
s.UPSName, s.Hostname, s.Model,
|
||||
s.UPSName, s.Hostname, s.Model, s.Status,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
|
@ -27,6 +27,7 @@ func TestUPSCollector(t *testing.T) {
|
||||
Hostname: "foo",
|
||||
Model: "APC UPS",
|
||||
UPSName: "bar",
|
||||
Status: "ONLINE",
|
||||
|
||||
BatteryChargePercent: 100.0,
|
||||
CumulativeTimeOnBattery: 30 * time.Second,
|
||||
@ -54,7 +55,7 @@ func TestUPSCollector(t *testing.T) {
|
||||
regexp.MustCompile(`apcupsd_battery_time_on_seconds{ups="bar"} 10`),
|
||||
regexp.MustCompile(`apcupsd_battery_volts{ups="bar"} 13.2`),
|
||||
regexp.MustCompile(`apcupsd_battery_number_transfers_total{ups="bar"} 1`),
|
||||
regexp.MustCompile(`apcupsd_info{hostname="foo",model="APC UPS",ups="bar"} 1`),
|
||||
regexp.MustCompile(`apcupsd_info{hostname="foo",model="APC UPS",status="ONLINE",ups="bar"} 1`),
|
||||
regexp.MustCompile(`apcupsd_line_nominal_volts{ups="bar"} 120`),
|
||||
regexp.MustCompile(`apcupsd_line_volts{ups="bar"} 121.1`),
|
||||
regexp.MustCompile(`apcupsd_output_volts{ups="bar"} 120.9`),
|
||||
|
Loading…
Reference in New Issue
Block a user