unifiexporter

package module
v0.0.0-...-b20d7e6 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2017 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.

Usage

Available flags for unifi_exporter include:

$ ./unifi_exporter -h
Usage of ./unifi_exporter:
  -telemetry.addr string
        host:port for UniFi exporter (default ":9130")
  -telemetry.path string
        URL path for surfacing collected metrics (default "/metrics")
  -unifi.addr string
        address of UniFi Controller API
  -unifi.insecure
        [optional] do not verify TLS certificate for UniFi Controller API (warning: please use carefully)
  -unifi.password string
        password for authentication against UniFi Controller API
  -unifi.site string
        [optional] description of site to collect metrics for using UniFi Controller API; if none specified, all sites will be scraped
  -unifi.timeout duration
        [optional] timeout for UniFi Controller API requests (default 5s)
  -unifi.username string
        username for authentication against UniFi Controller API

An example of using unifi_exporter with authentication:

$ ./unifi_exporter -unifi.addr https://unifi.example.com:8443/ -unifi.username admin -unifi.password password
2016/02/24 13:41:34 Starting UniFi exporter on ":9130" for site(s): Foo, Bar, Baz

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