From 420d526dee005b3fe44803d7122a5abdfb1edf8a Mon Sep 17 00:00:00 2001 From: Matt Layher Date: Mon, 14 Mar 2022 11:53:16 -0400 Subject: [PATCH] apcupsd_exporter: use temperature_celius suffix for internal temp Signed-off-by: Matt Layher --- upscollector.go | 10 +++++----- upscollector_test.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/upscollector.go b/upscollector.go index d2289eb..d0b536e 100644 --- a/upscollector.go +++ b/upscollector.go @@ -35,7 +35,7 @@ type UPSCollector struct { LastTransferOffBatteryTimeSeconds *prometheus.Desc LastSelftestTimeSeconds *prometheus.Desc NominalPowerWatts *prometheus.Desc - InternalTemp *prometheus.Desc + InternalTemperatureCelsius *prometheus.Desc ss StatusSource } @@ -159,8 +159,8 @@ func NewUPSCollector(ss StatusSource) *UPSCollector { nil, ), - InternalTemp: prometheus.NewDesc( - prometheus.BuildFQName(namespace, "", "internal_temp"), + InternalTemperatureCelsius: prometheus.NewDesc( + prometheus.BuildFQName(namespace, "", "internal_temperature_celsius"), "Internal temperature in °C.", labels, nil, @@ -190,7 +190,7 @@ func (c *UPSCollector) Describe(ch chan<- *prometheus.Desc) { c.LastTransferOffBatteryTimeSeconds, c.LastSelftestTimeSeconds, c.NominalPowerWatts, - c.InternalTemp, + c.InternalTemperatureCelsius, } for _, d := range ds { @@ -321,7 +321,7 @@ func (c *UPSCollector) Collect(ch chan<- prometheus.Metric) { ) ch <- prometheus.MustNewConstMetric( - c.InternalTemp, + c.InternalTemperatureCelsius, prometheus.GaugeValue, s.InternalTemp, s.UPSName, diff --git a/upscollector_test.go b/upscollector_test.go index 0048897..bafb11d 100644 --- a/upscollector_test.go +++ b/upscollector_test.go @@ -9,7 +9,7 @@ import ( ) func TestUPSCollector(t *testing.T) { - var tests = []struct { + tests := []struct { desc string ss *testStatusSource matches []*regexp.Regexp @@ -63,7 +63,7 @@ func TestUPSCollector(t *testing.T) { regexp.MustCompile(`apcupsd_last_transfer_off_battery_time_seconds{ups="bar"} 100002`), regexp.MustCompile(`apcupsd_last_selftest_time_seconds{ups="bar"} 100003`), regexp.MustCompile(`apcupsd_nominal_power_watts{ups="bar"} 50`), - regexp.MustCompile(`apcupsd_internal_temp{ups="bar"} 26.4`), + regexp.MustCompile(`apcupsd_internal_temperature_celsius{ups="bar"} 26.4`), }, }, }