apcupsdexporter

package module
v0.0.0-...-7dd9757 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2019 License: MIT Imports: 6 Imported by: 0

README

apcupsd_exporter Build Status GoDoc Docker Automated build

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

Docker

Docker Hub repository

iodeveloper/prom_apcupsdexporter

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")

Docker

https://hub.docker.com/r/iodeveloper/prom_apcupsdexporter

iodeveloper/prom_apcupsdexporter:latest

docker-compose.yml example:

version: '3.4'

services:

  apcupsd-home-main:
    image: iodeveloper/prom_apcupsdexporter:latest
    user: root
    privileged: true
    restart: unless-stopped
    network_mode: "host"
    command: /apcupsd_exporter -apcupsd.addr="0.0.0.0:3551" -telemetry.addr="172.101.0.1:10001"
    
  apcupsd-home-server:
    image: iodeveloper/prom_apcupsdexporter:latest
    user: root
    privileged: true
    restart: unless-stopped
    network_mode: "host"
    command: /apcupsd_exporter -apcupsd.addr="0.0.0.0:3552" -telemetry.addr="172.101.0.1:10002"

Sample

Here is a screenshot of an example grafana dashboard (/examples/grafana-dashboard.json) using metrics from apcupsd_exporter.

Grafana 1

Grafana 2

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() (*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 {
	// 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, nominalPower float64) *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 {
	Status                              *prometheus.Desc
	UPSLoadPercent                      *prometheus.Desc
	BatteryChargePercent                *prometheus.Desc
	LineVolts                           *prometheus.Desc
	LineNominalVolts                    *prometheus.Desc
	BatteryVolts                        *prometheus.Desc
	BatteryNominalVolts                 *prometheus.Desc
	BatteryNumberTransfersTotal         *prometheus.Desc
	BatteryTimeLeftSeconds              *prometheus.Desc
	BatteryTimeOnSeconds                *prometheus.Desc
	BatteryCumulativeTimeOnSecondsTotal *prometheus.Desc
	LastTransferOnBattery               *prometheus.Desc
	LastTransferOffBattery              *prometheus.Desc
	LastSelftest                        *prometheus.Desc
	NominalPowerWatts                   *prometheus.Desc
	InternalTemp                        *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, nominalPower float64) *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 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