apcupsdexporter

package module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 8 Imported by: 0

README

apcupsd_exporter Linux Test Status GoDoc

Command apcupsd_exporter provides a Prometheus exporter for the apcupsd Network Information Server (NIS). MIT Licensed.

Usage

Available flags for apcupsd_exporter include:

$ ./apcupsd_exporter -h
Usage of ./apcupsd_exporter:
  -apcupsd.addr string
        address of apcupsd Network Information Server (NIS) (default ":3551")
  -apcupsd.network string
        network of apcupsd Network Information Server (NIS): typically "tcp", "tcp4", or "tcp6" (default "tcp")
  -telemetry.addr string
        address for apcupsd exporter (default ":9162")
  -telemetry.path string
        URL path for surfacing collected metrics (default "/metrics")

Documentation

Overview

Package apcupsdexporter provides the Exporter type used in the apcupsd_exporter Prometheus exporter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientFunc

type ClientFunc func(ctx context.Context) (*apcupsd.Client, error)

A ClientFunc is a function which can return an apcupsd NIS client. ClientFuncs are invoked on each Prometheus scrape, so that connections can be short-lived and less likely to time out or fail.

type Exporter

type Exporter struct {
	Up *prometheus.Desc
	// contains filtered or unexported fields
}

An Exporter is a Prometheus exporter for apcupsd metrics. It wraps all apcupsd metrics collectors and provides a single global exporter which can serve metrics.

It implements the prometheus.Collector interface in order to register with Prometheus.

func New

func New(fn ClientFunc, logger log.Logger) *Exporter

New creates a new Exporter which collects metrics by creating a apcupsd client using the input ClientFunc.

func (*Exporter) Collect

func (e *Exporter) Collect(ch chan<- prometheus.Metric)

Collect sends the collected metrics from each of the collectors to prometheus.

func (*Exporter) Describe

func (e *Exporter) Describe(ch chan<- *prometheus.Desc)

Describe sends all the descriptors of the collectors included to the provided channel.

type StatusSource

type StatusSource interface {
	Status() (*apcupsd.Status, error)
}

A StatusSource is a type which can retrieve UPS status information from apcupsd. It is implemented by *apcupsd.Client.

type UPSCollector

type UPSCollector struct {
	Info *prometheus.Desc

	UPSLoadPercent                      *prometheus.Desc
	BatteryChargePercent                *prometheus.Desc
	LineVolts                           *prometheus.Desc
	LineNominalVolts                    *prometheus.Desc
	OutputVolts                         *prometheus.Desc
	OutputAmps                          *prometheus.Desc
	BatteryVolts                        *prometheus.Desc
	BatteryNominalVolts                 *prometheus.Desc
	BatteryNumberTransfersTotal         *prometheus.Desc
	BatteryTimeLeftSeconds              *prometheus.Desc
	BatteryTimeOnSeconds                *prometheus.Desc
	BatteryCumulativeTimeOnSecondsTotal *prometheus.Desc
	LastTransferOnBatteryTimeSeconds    *prometheus.Desc
	LastTransferOffBatteryTimeSeconds   *prometheus.Desc
	LastSelftestTimeSeconds             *prometheus.Desc
	NominalPowerWatts                   *prometheus.Desc
	InternalTemperatureCelsius          *prometheus.Desc
	// contains filtered or unexported fields
}

A UPSCollector is a Prometheus collector for metrics regarding an APC UPS.

func NewUPSCollector

func NewUPSCollector(ss StatusSource) *UPSCollector

NewUPSCollector creates a new UPSCollector.

func (*UPSCollector) Collect

func (c *UPSCollector) Collect(ch chan<- prometheus.Metric)

Collect sends the metric values for each metric created by the UPSCollector to the provided prometheus Metric channel.

func (*UPSCollector) Describe

func (c *UPSCollector) Describe(ch chan<- *prometheus.Desc)

Describe sends the descriptors of each metric over to the provided channel. The corresponding metric values are sent separately.

Directories

Path Synopsis
cmd
apcupsd_exporter command
Command apcupsd_exporter provides a Prometheus exporter for apcupsd.
Command apcupsd_exporter provides a Prometheus exporter for apcupsd.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL