@@ -34,6 +34,7 @@ type UPSCollector struct {
3434 LastTransferOnBatteryTimeSeconds * prometheus.Desc
3535 LastTransferOffBatteryTimeSeconds * prometheus.Desc
3636 LastSelftestTimeSeconds * prometheus.Desc
37+ LastTransferOnBatteryReason * prometheus.Desc
3738 NominalPowerWatts * prometheus.Desc
3839 InternalTemperatureCelsius * prometheus.Desc
3940
@@ -152,6 +153,13 @@ func NewUPSCollector(ss StatusSource) *UPSCollector {
152153 nil ,
153154 ),
154155
156+ LastTransferOnBatteryReason : prometheus .NewDesc (
157+ prometheus .BuildFQName (namespace , "" , "last_transfer_on_battery_reason" ),
158+ "Reason for last transfer to battery." ,
159+ []string {"reason" , "ups" },
160+ nil ,
161+ ),
162+
155163 NominalPowerWatts : prometheus .NewDesc (
156164 prometheus .BuildFQName (namespace , "" , "nominal_power_watts" ),
157165 "Nominal power output in watts." ,
@@ -189,6 +197,7 @@ func (c *UPSCollector) Describe(ch chan<- *prometheus.Desc) {
189197 c .LastTransferOnBatteryTimeSeconds ,
190198 c .LastTransferOffBatteryTimeSeconds ,
191199 c .LastSelftestTimeSeconds ,
200+ c .LastTransferOnBatteryReason ,
192201 c .NominalPowerWatts ,
193202 c .InternalTemperatureCelsius ,
194203 }
@@ -313,6 +322,14 @@ func (c *UPSCollector) Collect(ch chan<- prometheus.Metric) {
313322 s .UPSName ,
314323 )
315324
325+ ch <- prometheus .MustNewConstMetric (
326+ c .LastTransferOnBatteryReason ,
327+ prometheus .GaugeValue ,
328+ 1 ,
329+ s .LastTransfer ,
330+ s .UPSName ,
331+ )
332+
316333 ch <- prometheus .MustNewConstMetric (
317334 c .NominalPowerWatts ,
318335 prometheus .GaugeValue ,
0 commit comments