From 3071cb4345e477042d7798086c7bbe2972bf71dd Mon Sep 17 00:00:00 2001 From: Lars Date: Wed, 2 Aug 2023 10:47:09 +0000 Subject: [PATCH 1/2] Add metric for output amps --- upscollector.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/upscollector.go b/upscollector.go index e838c28..da1852e 100644 --- a/upscollector.go +++ b/upscollector.go @@ -25,6 +25,7 @@ type UPSCollector struct { LineVolts *prometheus.Desc LineNominalVolts *prometheus.Desc OutputVolts *prometheus.Desc + OutputAmps *prometheus.Desc BatteryVolts *prometheus.Desc BatteryNominalVolts *prometheus.Desc BatteryNumberTransfersTotal *prometheus.Desc @@ -89,6 +90,13 @@ func NewUPSCollector(ss StatusSource) *UPSCollector { nil, ), + OutputAmps: prometheus.NewDesc( + prometheus.BuildFQName(namespace, "", "output_amps"), + "Current ampere draw on output.", + labels, + nil, + ), + BatteryVolts: prometheus.NewDesc( prometheus.BuildFQName(namespace, "", "battery_volts"), "Current UPS battery voltage.", @@ -180,6 +188,7 @@ func (c *UPSCollector) Describe(ch chan<- *prometheus.Desc) { c.LineVolts, c.LineNominalVolts, c.OutputVolts, + c.OutputAmps, c.BatteryVolts, c.BatteryNominalVolts, c.BatteryNumberTransfersTotal, @@ -250,6 +259,13 @@ func (c *UPSCollector) Collect(ch chan<- prometheus.Metric) { s.UPSName, ) + ch <- prometheus.MustNewConstMetric( + c.OutputAmps, + prometheus.GaugeValue, + s.OutputAmps, + s.UPSName, + ) + ch <- prometheus.MustNewConstMetric( c.BatteryVolts, prometheus.GaugeValue, From c1feeaec2455b8844cf1bc225353200906b7f75c Mon Sep 17 00:00:00 2001 From: Lars Date: Wed, 2 Aug 2023 11:19:23 +0000 Subject: [PATCH 2/2] update to own module --- upscollector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upscollector.go b/upscollector.go index da1852e..6bf37f8 100644 --- a/upscollector.go +++ b/upscollector.go @@ -4,7 +4,7 @@ import ( "log" "time" - "github.com/mdlayher/apcupsd" + "github.com/Supporterino/apcupsd" "github.com/prometheus/client_golang/prometheus" )