unifiexporter

package module
v0.0.0-...-74ae14e Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 5 Imported by: 0

README

unifi_exporter GoDoc Build Status Coverage Status

Command unifi_exporter provides a Prometheus exporter for a Ubiquiti UniFi Controller API and UniFi devices.

Package unifiexporter provides the Exporter type used in the unifi_exporter Prometheus exporter.

MIT Licensed.

Seeking additional maintainers

Due to the wide variety of UniFi devices available, and because the UniFi APIs are unstable, Matt Layher is unable to dedicate the time and energy needed to maintain this exporter on his own.

At this time, there are no official releases or Docker images available. Building the exporter from master is the expected method to deploy it.

If you are interested in maintaining this exporter and have demonstrated a history of submitting solid improvements to the project, I am happy to grant push access to remove myself as a roadblock for progress.

Usage

$ ./unifi_exporter -h
Usage of ./unifi_exporter:
  -config.file string
       Relative path to config file yaml

To run the exporter, edit the included config.yml.example, rename it to config.yml, then run the exporter like so:

$ ./unifi_exporter -config.file config.yml
2017/11/15 17:06:32 [INFO] successfully authenticated to UniFi controller
2017/11/15 17:06:32 Starting UniFi exporter on ":9130" for site(s): Default

The minimum you'll need to modify is the unifi address, username and password. The port defaults to 8443 as specified in the config file, and the defaults in 'listen' are sufficient for most users.

Sample

Here is a screenshot of a sample dashboard created using grafana with metrics from exported from unifi_exporter.

sample

Thanks

Special thanks to Vaibhav Bhembre for his work on ceph_exporter. ceph_exporter was used frequently as a reference Prometheus exporter while implementing unifi_exporter.

Documentation

Overview

Package unifiexporter provides the Exporter type used in the unifi_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() (*unifi.Client, error)

A ClientFunc is a function which can return an authenticated UniFi client. A ClientFunc is invoked by an Exporter whenever authentication against a UniFi controller fails, such as when a user's privileges are revoked or the authenticated session times out.

type DeviceCollector

type DeviceCollector struct {
	Devices          *prometheus.Desc
	AdoptedDevices   *prometheus.Desc
	UnadoptedDevices *prometheus.Desc

	UptimeSecondsTotal *prometheus.Desc

	WirelessReceivedBytesTotal    *prometheus.Desc
	WirelessTransmittedBytesTotal *prometheus.Desc

	WirelessReceivedPacketsTotal    *prometheus.Desc
	WirelessTransmittedPacketsTotal *prometheus.Desc
	WirelessTransmittedDroppedTotal *prometheus.Desc

	WiredReceivedBytesTotal    *prometheus.Desc
	WiredTransmittedBytesTotal *prometheus.Desc

	WiredReceivedPacketsTotal    *prometheus.Desc
	WiredTransmittedPacketsTotal *prometheus.Desc

	Stations      *prometheus.Desc
	UserStations  *prometheus.Desc
	GuestStations *prometheus.Desc
	// contains filtered or unexported fields
}

A DeviceCollector is a Prometheus collector for metrics regarding Ubiquiti UniFi devices.

func NewDeviceCollector

func NewDeviceCollector(c *unifi.Client, sites []*unifi.Site) *DeviceCollector

NewDeviceCollector creates a new DeviceCollector which collects metrics for a specified site.

func (*DeviceCollector) Collect

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

Collect is the same as CollectError, but ignores any errors which occur. Collect exists to satisfy the prometheus.Collector interface.

func (*DeviceCollector) CollectError

func (c *DeviceCollector) CollectError(ch chan<- prometheus.Metric) error

CollectError sends the metric values for each metric pertaining to the global cluster usage over to the provided prometheus Metric channel, returning any errors which occur.

func (*DeviceCollector) Describe

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

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

type Exporter

type Exporter struct {
	// contains filtered or unexported fields
}

An Exporter is a Prometheus exporter for Ubiquiti UniFi Controller API metrics. It wraps all UniFi metrics collectors and provides a single global exporter which can serve metrics. It also ensures that the collection is done in a thread-safe manner, the necessary requirement stated by Prometheus. It implements the prometheus.Collector interface in order to register with Prometheus.

func New

func New(sites []*unifi.Site, fn ClientFunc) (*Exporter, error)

New creates a new Exporter which collects metrics from one or mote sites.

func (*Exporter) Collect

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

Collect sends the collected metrics from each of the collectors to prometheus. Collect could be called several times concurrently and thus its run is protected by a single mutex.

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 StationCollector

type StationCollector struct {
	Stations *prometheus.Desc

	ReceivedBytesTotal    *prometheus.Desc
	TransmittedBytesTotal *prometheus.Desc

	ReceivedPacketsTotal    *prometheus.Desc
	TransmittedPacketsTotal *prometheus.Desc

	RSSIDBM  *prometheus.Desc
	NoiseDBM *prometheus.Desc
	// contains filtered or unexported fields
}

A StationCollector is a Prometheus collector for metrics regarding Ubiquiti UniFi stations (clients).

func NewStationCollector

func NewStationCollector(c *unifi.Client, sites []*unifi.Site) *StationCollector

NewStationCollector creates a new StationCollector which collects metrics for a specified site.

func (*StationCollector) Collect

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

Collect is the same as Collect, but ignores any errors which occur. Collect exists to satisfy the prometheus.Collector interface.

func (*StationCollector) CollectError

func (c *StationCollector) CollectError(ch chan<- prometheus.Metric) error

CollectError sends the metric values for each metric pertaining to the global cluster usage over to the provided prometheus Metric channel, returning any errors which occur.

func (*StationCollector) Describe

func (c *StationCollector) 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
unifi_exporter
Command unifi_exporter provides a Prometheus exporter for a Ubiquiti UniFi Controller API and UniFi devices.
Command unifi_exporter provides a Prometheus exporter for a Ubiquiti UniFi Controller API and UniFi devices.

Jump to

Keyboard shortcuts

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