apcupsd_exporter: add OutputVolts and InternalTemp (#15)
Co-authored-by: Malte Bögershausen <malteb@gmail.com>
This commit is contained in:
parent
6cf5b5de9a
commit
4f14ba2aa6
|
@ -24,6 +24,7 @@ type UPSCollector struct {
|
||||||
BatteryChargePercent *prometheus.Desc
|
BatteryChargePercent *prometheus.Desc
|
||||||
LineVolts *prometheus.Desc
|
LineVolts *prometheus.Desc
|
||||||
LineNominalVolts *prometheus.Desc
|
LineNominalVolts *prometheus.Desc
|
||||||
|
OutputVolts *prometheus.Desc
|
||||||
BatteryVolts *prometheus.Desc
|
BatteryVolts *prometheus.Desc
|
||||||
BatteryNominalVolts *prometheus.Desc
|
BatteryNominalVolts *prometheus.Desc
|
||||||
BatteryNumberTransfersTotal *prometheus.Desc
|
BatteryNumberTransfersTotal *prometheus.Desc
|
||||||
|
@ -34,6 +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
|
||||||
|
|
||||||
ss StatusSource
|
ss StatusSource
|
||||||
}
|
}
|
||||||
|
@ -80,6 +82,13 @@ func NewUPSCollector(ss StatusSource) *UPSCollector {
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
OutputVolts: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(namespace, "", "output_volts"),
|
||||||
|
"Current AC output voltage.",
|
||||||
|
labels,
|
||||||
|
nil,
|
||||||
|
),
|
||||||
|
|
||||||
BatteryVolts: prometheus.NewDesc(
|
BatteryVolts: prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(namespace, "", "battery_volts"),
|
prometheus.BuildFQName(namespace, "", "battery_volts"),
|
||||||
"Current UPS battery voltage.",
|
"Current UPS battery voltage.",
|
||||||
|
@ -150,6 +159,13 @@ func NewUPSCollector(ss StatusSource) *UPSCollector {
|
||||||
nil,
|
nil,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
InternalTemp: prometheus.NewDesc(
|
||||||
|
prometheus.BuildFQName(namespace, "", "internal_temp"),
|
||||||
|
"Internal temperature in °C.",
|
||||||
|
labels,
|
||||||
|
nil,
|
||||||
|
),
|
||||||
|
|
||||||
ss: ss,
|
ss: ss,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,6 +179,7 @@ func (c *UPSCollector) Describe(ch chan<- *prometheus.Desc) {
|
||||||
c.BatteryChargePercent,
|
c.BatteryChargePercent,
|
||||||
c.LineVolts,
|
c.LineVolts,
|
||||||
c.LineNominalVolts,
|
c.LineNominalVolts,
|
||||||
|
c.OutputVolts,
|
||||||
c.BatteryVolts,
|
c.BatteryVolts,
|
||||||
c.BatteryNominalVolts,
|
c.BatteryNominalVolts,
|
||||||
c.BatteryNumberTransfersTotal,
|
c.BatteryNumberTransfersTotal,
|
||||||
|
@ -173,6 +190,7 @@ func (c *UPSCollector) Describe(ch chan<- *prometheus.Desc) {
|
||||||
c.LastTransferOffBatteryTimeSeconds,
|
c.LastTransferOffBatteryTimeSeconds,
|
||||||
c.LastSelftestTimeSeconds,
|
c.LastSelftestTimeSeconds,
|
||||||
c.NominalPowerWatts,
|
c.NominalPowerWatts,
|
||||||
|
c.InternalTemp,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, d := range ds {
|
for _, d := range ds {
|
||||||
|
@ -225,6 +243,13 @@ func (c *UPSCollector) Collect(ch chan<- prometheus.Metric) {
|
||||||
s.UPSName,
|
s.UPSName,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.OutputVolts,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
s.OutputVoltage,
|
||||||
|
s.UPSName,
|
||||||
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.BatteryVolts,
|
c.BatteryVolts,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
|
@ -294,6 +319,13 @@ func (c *UPSCollector) Collect(ch chan<- prometheus.Metric) {
|
||||||
float64(s.NominalPower),
|
float64(s.NominalPower),
|
||||||
s.UPSName,
|
s.UPSName,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.InternalTemp,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
s.InternalTemp,
|
||||||
|
s.UPSName,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func timestamp(t time.Time) float64 {
|
func timestamp(t time.Time) float64 {
|
||||||
|
|
|
@ -36,12 +36,14 @@ func TestUPSCollector(t *testing.T) {
|
||||||
BatteryVoltage: 13.2,
|
BatteryVoltage: 13.2,
|
||||||
NominalInputVoltage: 120.0,
|
NominalInputVoltage: 120.0,
|
||||||
LineVoltage: 121.1,
|
LineVoltage: 121.1,
|
||||||
|
OutputVoltage: 120.9,
|
||||||
LoadPercent: 16.0,
|
LoadPercent: 16.0,
|
||||||
NumberTransfers: 1,
|
NumberTransfers: 1,
|
||||||
XOnBattery: time.Unix(100001, 0),
|
XOnBattery: time.Unix(100001, 0),
|
||||||
XOffBattery: time.Unix(100002, 0),
|
XOffBattery: time.Unix(100002, 0),
|
||||||
LastSelftest: time.Unix(100003, 0),
|
LastSelftest: time.Unix(100003, 0),
|
||||||
NominalPower: 50.0,
|
NominalPower: 50.0,
|
||||||
|
InternalTemp: 26.4,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
matches: []*regexp.Regexp{
|
matches: []*regexp.Regexp{
|
||||||
|
@ -55,11 +57,13 @@ func TestUPSCollector(t *testing.T) {
|
||||||
regexp.MustCompile(`apcupsd_info{hostname="foo",model="APC UPS",ups="bar"} 1`),
|
regexp.MustCompile(`apcupsd_info{hostname="foo",model="APC UPS",ups="bar"} 1`),
|
||||||
regexp.MustCompile(`apcupsd_line_nominal_volts{ups="bar"} 120`),
|
regexp.MustCompile(`apcupsd_line_nominal_volts{ups="bar"} 120`),
|
||||||
regexp.MustCompile(`apcupsd_line_volts{ups="bar"} 121.1`),
|
regexp.MustCompile(`apcupsd_line_volts{ups="bar"} 121.1`),
|
||||||
|
regexp.MustCompile(`apcupsd_output_volts{ups="bar"} 120.9`),
|
||||||
regexp.MustCompile(`apcupsd_ups_load_percent{ups="bar"} 16`),
|
regexp.MustCompile(`apcupsd_ups_load_percent{ups="bar"} 16`),
|
||||||
regexp.MustCompile(`apcupsd_last_transfer_on_battery_time_seconds{ups="bar"} 100001`),
|
regexp.MustCompile(`apcupsd_last_transfer_on_battery_time_seconds{ups="bar"} 100001`),
|
||||||
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`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue