apcupsd_exporter: use temperature_celius suffix for internal temp

Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
Matt Layher 2022-03-14 11:53:16 -04:00
parent 4f14ba2aa6
commit 420d526dee
No known key found for this signature in database
GPG Key ID: 77BFE531397EDE94
2 changed files with 7 additions and 7 deletions

View File

@ -35,7 +35,7 @@ type UPSCollector struct {
LastTransferOffBatteryTimeSeconds *prometheus.Desc LastTransferOffBatteryTimeSeconds *prometheus.Desc
LastSelftestTimeSeconds *prometheus.Desc LastSelftestTimeSeconds *prometheus.Desc
NominalPowerWatts *prometheus.Desc NominalPowerWatts *prometheus.Desc
InternalTemp *prometheus.Desc InternalTemperatureCelsius *prometheus.Desc
ss StatusSource ss StatusSource
} }
@ -159,8 +159,8 @@ func NewUPSCollector(ss StatusSource) *UPSCollector {
nil, nil,
), ),
InternalTemp: prometheus.NewDesc( InternalTemperatureCelsius: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "internal_temp"), prometheus.BuildFQName(namespace, "", "internal_temperature_celsius"),
"Internal temperature in °C.", "Internal temperature in °C.",
labels, labels,
nil, nil,
@ -190,7 +190,7 @@ func (c *UPSCollector) Describe(ch chan<- *prometheus.Desc) {
c.LastTransferOffBatteryTimeSeconds, c.LastTransferOffBatteryTimeSeconds,
c.LastSelftestTimeSeconds, c.LastSelftestTimeSeconds,
c.NominalPowerWatts, c.NominalPowerWatts,
c.InternalTemp, c.InternalTemperatureCelsius,
} }
for _, d := range ds { for _, d := range ds {
@ -321,7 +321,7 @@ func (c *UPSCollector) Collect(ch chan<- prometheus.Metric) {
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.InternalTemp, c.InternalTemperatureCelsius,
prometheus.GaugeValue, prometheus.GaugeValue,
s.InternalTemp, s.InternalTemp,
s.UPSName, s.UPSName,

View File

@ -9,7 +9,7 @@ import (
) )
func TestUPSCollector(t *testing.T) { func TestUPSCollector(t *testing.T) {
var tests = []struct { tests := []struct {
desc string desc string
ss *testStatusSource ss *testStatusSource
matches []*regexp.Regexp 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_transfer_off_battery_time_seconds{ups="bar"} 100002`),
regexp.MustCompile(`apcupsd_last_selftest_time_seconds{ups="bar"} 100003`), regexp.MustCompile(`apcupsd_last_selftest_time_seconds{ups="bar"} 100003`),
regexp.MustCompile(`apcupsd_nominal_power_watts{ups="bar"} 50`), 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`),
}, },
}, },
} }