inputunifi

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 10 Imported by: 0

README

inputunifi

UniFi Poller Input Plugin

Documentation

Overview

Package inputunifi implements the poller.Input interface and bridges the gap between metrics from the unifi library, and the augments required to pump them into unifi-poller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RedactMacPII added in v0.0.7

func RedactMacPII(pii string, hash *bool) (output string)

RedactMacPII converts a MAC address to an md5 hashed version (first 14 chars only). Useful for maskiing out personally identifying information.

func RedactNamePII added in v0.0.7

func RedactNamePII(pii string, hash *bool) string

RedactNamePII converts a name string to an md5 hash (first 24 chars only). Useful for maskiing out personally identifying information.

func StringInSlice

func StringInSlice(str string, slice []string) bool

StringInSlice returns true if a string is in a slice.

Types

type Config

type Config struct {
	sync.RWMutex               // locks the Unifi struct member when re-authing to unifi.
	Default      Controller    `json:"defaults" toml:"defaults" xml:"default" yaml:"defaults"`
	Disable      bool          `json:"disable" toml:"disable" xml:"disable,attr" yaml:"disable"`
	Dynamic      bool          `json:"dynamic" toml:"dynamic" xml:"dynamic,attr" yaml:"dynamic"`
	Controllers  []*Controller `json:"controllers" toml:"controller" xml:"controller" yaml:"controllers"`
}

Config contains our configuration data.

type Controller

type Controller struct {
	VerifySSL *bool        `json:"verify_ssl" toml:"verify_ssl" xml:"verify_ssl" yaml:"verify_ssl"`
	SaveIDS   *bool        `json:"save_ids" toml:"save_ids" xml:"save_ids" yaml:"save_ids"`
	SaveDPI   *bool        `json:"save_dpi" toml:"save_dpi" xml:"save_dpi" yaml:"save_dpi"`
	HashPII   *bool        `json:"hash_pii" toml:"hash_pii" xml:"hash_pii" yaml:"hash_pii"`
	SaveSites *bool        `json:"save_sites" toml:"save_sites" xml:"save_sites" yaml:"save_sites"`
	User      string       `json:"user" toml:"user" xml:"user" yaml:"user"`
	Pass      string       `json:"pass" toml:"pass" xml:"pass" yaml:"pass"`
	URL       string       `json:"url" toml:"url" xml:"url" yaml:"url"`
	Sites     []string     `json:"sites,omitempty" toml:"sites,omitempty" xml:"site" yaml:"sites"`
	Unifi     *unifi.Unifi `json:"-" toml:"-" xml:"-" yaml:"-"`
}

Controller represents the configuration for a UniFi Controller. Each polled controller may have its own configuration.

type InputUnifi

type InputUnifi struct {
	*Config `json:"unifi" toml:"unifi" xml:"unifi" yaml:"unifi"`

	sync.Mutex // to lock the map above.
	poller.Logger
	// contains filtered or unexported fields
}

InputUnifi contains the running data.

func (*InputUnifi) Initialize

func (u *InputUnifi) Initialize(l poller.Logger) error

Initialize gets called one time when starting up. Satisfies poller.Input interface.

func (*InputUnifi) Metrics

func (u *InputUnifi) Metrics() (*poller.Metrics, bool, error)

Metrics grabs all the measurements from a UniFi controller and returns them.

func (*InputUnifi) MetricsFrom

func (u *InputUnifi) MetricsFrom(filter *poller.Filter) (*poller.Metrics, bool, error)

MetricsFrom grabs all the measurements from a UniFi controller and returns them.

func (*InputUnifi) RawMetrics

func (u *InputUnifi) RawMetrics(filter *poller.Filter) ([]byte, error)

RawMetrics returns API output from the first configured unifi controller.

Jump to

Keyboard shortcuts

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