Documentation
¶
Overview ¶
Package influxunifi provides the methods to turn UniFi measurements into influx data-points with appropriate tags and fields.
Index ¶
- Constants
- func Combine(in ...map[string]any) map[string]any
- type Config
- type Counts
- type InfluxDB
- type InfluxUnifi
- func (u *InfluxUnifi) DebugOutput() (bool, error)
- func (u *InfluxUnifi) Enabled() bool
- func (u *InfluxUnifi) LogDebugf(msg string, v ...any)
- func (u *InfluxUnifi) LogErrorf(msg string, v ...any)
- func (u *InfluxUnifi) Logf(msg string, v ...any)
- func (u *InfluxUnifi) PollController()
- func (u *InfluxUnifi) ReportMetrics(m *poller.Metrics, e *poller.Events) (*Report, error)
- func (u *InfluxUnifi) Run(c poller.Collect) error
- type Report
Constants ¶
const PluginName = "influxdb"
PluginName is the name of this plugin.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Interval cnfg.Duration `json:"interval,omitempty" toml:"interval,omitempty" xml:"interval" yaml:"interval"`
// Pass controls the influxdb v1 password to write metrics with
Pass string `json:"pass,omitempty" toml:"pass,omitempty" xml:"pass" yaml:"pass"`
// User controls the influxdb v1 user to write metrics with
User string `json:"user,omitempty" toml:"user,omitempty" xml:"user" yaml:"user"`
// DB controls the influxdb v1 database to write metrics to
DB string `json:"db,omitempty" toml:"db,omitempty" xml:"db" yaml:"db"`
// AuthToken is the secret for v2 influxdb
AuthToken string `json:"auth_token,omitempty" toml:"auth_token,omitempty" xml:"auth_token" yaml:"auth_token"`
// Org is the influx org to put metrics under for v2 influxdb
Org string `json:"org,omitempty" toml:"org,omitempty" xml:"org" yaml:"org"`
// Bucket is the influx bucket to put metrics under for v2 influxdb
Bucket string `json:"bucket,omitempty" toml:"bucket,omitempty" xml:"bucket" yaml:"bucket"`
// BatchSize controls the async batch size for v2 influxdb client mode
BatchSize uint `json:"batch_size,omitempty" toml:"batch_size,omitempty" xml:"batch_size" yaml:"batch_size"`
// URL details which influxdb url to use to report metrics to.
URL string `json:"url,omitempty" toml:"url,omitempty" xml:"url" yaml:"url"`
// Disable when true will disable the influxdb output.
Disable bool `json:"disable" toml:"disable" xml:"disable,attr" yaml:"disable"`
// VerifySSL when true will require ssl verification.
VerifySSL bool `json:"verify_ssl" toml:"verify_ssl" xml:"verify_ssl" yaml:"verify_ssl"`
// DeadPorts when true will save data for dead ports, for example ports that are down or disabled.
DeadPorts bool `json:"dead_ports" toml:"dead_ports" xml:"dead_ports" yaml:"dead_ports"`
}
Config defines the data needed to store metrics in InfluxDB.
type InfluxDB ¶
type InfluxDB struct {
*Config `json:"influxdb" toml:"influxdb" xml:"influxdb" yaml:"influxdb"`
}
InfluxDB allows the data to be nested in the config file.
type InfluxUnifi ¶
type InfluxUnifi struct {
Collector poller.Collect
LastCheck time.Time
IsVersion2 bool
*InfluxDB
// contains filtered or unexported fields
}
InfluxUnifi is returned by New() after you provide a Config.
func (*InfluxUnifi) DebugOutput ¶
func (u *InfluxUnifi) DebugOutput() (bool, error)
func (*InfluxUnifi) Enabled ¶
func (u *InfluxUnifi) Enabled() bool
func (*InfluxUnifi) LogDebugf ¶
func (u *InfluxUnifi) LogDebugf(msg string, v ...any)
LogDebugf logs a debug message.
func (*InfluxUnifi) LogErrorf ¶
func (u *InfluxUnifi) LogErrorf(msg string, v ...any)
LogErrorf logs an error message.
func (*InfluxUnifi) PollController ¶
func (u *InfluxUnifi) PollController()
PollController runs forever, polling UniFi and pushing to InfluxDB This is started by Run() or RunBoth() after everything checks out.
func (*InfluxUnifi) ReportMetrics ¶
ReportMetrics batches all device and client data into influxdb data points. Call this after you've collected all the data you care about. Returns an error if influxdb calls fail, otherwise returns a report.