Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metric for output amps #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion upscollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"time"

"github.com/mdlayher/apcupsd"
"github.com/Supporterino/apcupsd"
"github.com/prometheus/client_golang/prometheus"
)

Expand All @@ -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
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down