fixed start loop
This commit is contained in:
parent
4259d4f396
commit
fded91ce40
|
|
@ -56,6 +56,7 @@
|
|||
# Pick which logs you want per-controller in the [unifi.controller] section.
|
||||
# This is a new feature. Feedback welcome!
|
||||
[loki]
|
||||
disable = true
|
||||
url = ""
|
||||
# The rest of this is advanced & optional. See wiki.
|
||||
user = ""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
#influxdb
|
||||
INFLUXDB_HTTP_AUTH_ENABLED=true
|
||||
INFLUXDB_ADMIN_USER=unifi-poller
|
||||
INFLUXDB_ADMIN_USER=unpoller
|
||||
INFLUXDB_ADMIN_PASSWORD=CHANGEME
|
||||
INFLUXDB_DB=unifi
|
||||
INFLUXDB_DB=unpoller
|
||||
INFLUXDB_ORG=unpoller
|
||||
INFLUXDB_BUCKET=unpoller
|
||||
INFLUXDB_ADMIN_TOKEN=unpollersecret
|
||||
|
||||
#grafana
|
||||
GRAFANA_USERNAME=admin
|
||||
|
|
@ -12,6 +15,6 @@ GRAFANA_PASSWORD=grafanaadmin
|
|||
POLLER_TAG=latest
|
||||
POLLER_DEBUG=false
|
||||
POLLER_SAVE_DPI=false
|
||||
UNIFI_USER=unifipoller
|
||||
UNIFI_USER=unpoller
|
||||
UNIFI_PASS=set_this_on_your_controller
|
||||
UNIFI_URL=https://127.0.0.1:8443
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ version: '3'
|
|||
services:
|
||||
influxdb:
|
||||
restart: always
|
||||
image: influxdb:1.8
|
||||
image: influxdb:2.5
|
||||
ports:
|
||||
- '8086:8086'
|
||||
volumes:
|
||||
|
|
@ -11,8 +11,12 @@ services:
|
|||
environment:
|
||||
- INFLUXDB_DB=${INFLUXDB_DB}
|
||||
- INFLUXDB_HTTP_AUTH_ENABLED=${INFLUXDB_HTTP_AUTH_ENABLED}
|
||||
- INFLUXDB_ADMIN_USER=${INFLUXDB_ADMIN_USER}
|
||||
- INFLUXDB_ADMIN_PASSWORD=${INFLUXDB_ADMIN_PASSWORD}
|
||||
- DOCKER_INFLUXDB_INIT_MODE=setup
|
||||
- DOCKER_INFLUXDB_INIT_USERNAME=${INFLUXDB_ADMIN_USER}
|
||||
- DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUXDB_ADMIN_PASSWORD}
|
||||
- DOCKER_INFLUXDB_INIT_ORG=${INFLUXDB_ORG}
|
||||
- DOCKER_INFLUXDB_INIT_BUCKET=${INFLUXDB_BUCKET}
|
||||
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${INFLUXDB_ADMIN_TOKEN}
|
||||
chronograf:
|
||||
image: chronograf:latest
|
||||
restart: always
|
||||
|
|
@ -42,10 +46,17 @@ services:
|
|||
unifi-poller:
|
||||
restart: always
|
||||
image: ghcr.io/unpoller/unpoller:${POLLER_TAG}
|
||||
depends_on:
|
||||
- grafana
|
||||
- influxdb
|
||||
- chronograf
|
||||
environment:
|
||||
- UP_INFLUXDB_DB=${INFLUXDB_DB}
|
||||
- UP_INFLUXDB_USER=${INFLUXDB_ADMIN_USER}
|
||||
- UP_INFLUXDB_PASS=${INFLUXDB_ADMIN_PASSWORD}
|
||||
- UP_INFLUXDB_ORG=${INFLUXDB_ORG}
|
||||
- UP_INFLUXDB_BUCKET=${INFLUXDB_BUCKET}
|
||||
- UP_INFLUXDB_AUTH_TOKEN=${INFLUXDB_ADMIN_TOKEN}
|
||||
- UP_INFLUXDB_URL=http://influxdb:8086
|
||||
- UP_UNIFI_DEFAULT_USER=${UNIFI_USER}
|
||||
- UP_UNIFI_DEFAULT_PASS=${UNIFI_PASS}
|
||||
|
|
|
|||
|
|
@ -197,9 +197,6 @@ func (u *DatadogUnifi) Enabled() bool {
|
|||
if u.Enable == nil || u.Config == nil {
|
||||
return false
|
||||
}
|
||||
if u.Collector == nil {
|
||||
return false
|
||||
}
|
||||
return *u.Enable
|
||||
}
|
||||
|
||||
|
|
@ -207,10 +204,10 @@ func (u *DatadogUnifi) Enabled() bool {
|
|||
func (u *DatadogUnifi) Run(c poller.Collect) error {
|
||||
u.Collector = c
|
||||
if !u.Enabled() {
|
||||
u.Logf("DataDog config missing (or disabled), DataDog output disabled!")
|
||||
u.LogDebugf("DataDog config missing (or disabled), DataDog output disabled!")
|
||||
return nil
|
||||
}
|
||||
u.Logf("Datadog is configured.")
|
||||
u.Logf("Datadog is enabled")
|
||||
u.setConfigDefaults()
|
||||
|
||||
var err error
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ package influxunifi
|
|||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -53,11 +52,11 @@ type Config struct {
|
|||
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"`
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
}
|
||||
|
|
@ -105,8 +104,8 @@ func (u *InfluxUnifi) PollController() {
|
|||
if u.IsVersion2 {
|
||||
version = "2"
|
||||
}
|
||||
log.Printf("[INFO] Poller->InfluxDB started, version: %s, interval: %v, dp: %v, db: %s, url: %s",
|
||||
version, interval, u.DeadPorts, u.DB, u.URL)
|
||||
u.Logf("Poller->InfluxDB started, version: %s, interval: %v, dp: %v, db: %s, url: %s, bucket: %s, org: %s",
|
||||
version, interval, u.DeadPorts, u.DB, u.URL, u.Bucket, u.Org)
|
||||
|
||||
for u.LastCheck = range ticker.C {
|
||||
metrics, err := u.Collector.Metrics(&poller.Filter{Name: "unifi"})
|
||||
|
|
@ -139,9 +138,6 @@ func (u *InfluxUnifi) Enabled() bool {
|
|||
if u.Config == nil {
|
||||
return false
|
||||
}
|
||||
if u.Collector == nil {
|
||||
return false
|
||||
}
|
||||
return !u.Disable
|
||||
}
|
||||
|
||||
|
|
@ -149,10 +145,12 @@ func (u *InfluxUnifi) Enabled() bool {
|
|||
func (u *InfluxUnifi) Run(c poller.Collect) error {
|
||||
u.Collector = c
|
||||
if !u.Enabled() {
|
||||
u.Logf("InfluxDB config missing (or disabled), InfluxDB output disabled!")
|
||||
u.LogDebugf("InfluxDB config missing (or disabled), InfluxDB output disabled!")
|
||||
return nil
|
||||
}
|
||||
|
||||
u.Logf("InfluxDB enabled")
|
||||
|
||||
var err error
|
||||
|
||||
u.setConfigDefaults()
|
||||
|
|
|
|||
|
|
@ -70,16 +70,20 @@ func (l *Loki) Enabled() bool {
|
|||
if l.Config == nil {
|
||||
return false
|
||||
}
|
||||
if l.URL == "" {
|
||||
return false
|
||||
}
|
||||
return !l.Disable
|
||||
}
|
||||
|
||||
// Run is fired from the poller library after the Config is unmarshalled.
|
||||
func (l *Loki) Run(collect poller.Collect) error {
|
||||
l.Collect = collect
|
||||
if l.Config == nil || l.URL == "" || !l.Enabled() {
|
||||
l.Logf("Loki config missing (or disabled), Loki output disabled!")
|
||||
if !l.Enabled() {
|
||||
l.LogDebugf("Loki config missing (or disabled), Loki output disabled!")
|
||||
return nil
|
||||
}
|
||||
l.Logf("Loki enabled")
|
||||
|
||||
l.ValidateConfig()
|
||||
|
||||
|
|
|
|||
|
|
@ -63,9 +63,12 @@ func (u *UnifiPoller) InitializeInputs() error {
|
|||
|
||||
for _, input := range inputs {
|
||||
// This must return, or the app locks up here.
|
||||
u.LogDebugf("inititalizing input... %s", input.Name)
|
||||
if err := input.Initialize(u); err != nil {
|
||||
u.LogDebugf("error initializing input ... %s", input.Name)
|
||||
return err
|
||||
}
|
||||
u.LogDebugf("input successfully initialized ... %s", input.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -87,9 +87,12 @@ func (u *UnifiPoller) runOutputMethods() (int, chan error) {
|
|||
|
||||
for _, o := range outputs {
|
||||
if o != nil && o.Enabled() {
|
||||
u.LogDebugf("output plugin enabled, starting run loop for %s", o.Name)
|
||||
go func(o *Output) {
|
||||
err <- o.Run(u) // Run each output plugin
|
||||
}(o)
|
||||
} else {
|
||||
u.LogDebugf("output plugin disabled for %s", o.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,5 +94,7 @@ func (u *UnifiPoller) Run() error {
|
|||
return err
|
||||
}
|
||||
|
||||
u.LogDebugf("staring outputs")
|
||||
|
||||
return u.InitializeOutputs()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,9 +121,6 @@ func (u *promUnifi) Enabled() bool {
|
|||
if u.Config == nil {
|
||||
return false
|
||||
}
|
||||
if u.Collector == nil {
|
||||
return false
|
||||
}
|
||||
return !u.Disable
|
||||
}
|
||||
|
||||
|
|
@ -132,9 +129,10 @@ func (u *promUnifi) Enabled() bool {
|
|||
func (u *promUnifi) Run(c poller.Collect) error {
|
||||
u.Collector = c
|
||||
if u.Config == nil || !u.Enabled() {
|
||||
u.Logf("Prometheus config missing (or disabled), Prometheus HTTP listener disabled!")
|
||||
u.LogDebugf("Prometheus config missing (or disabled), Prometheus HTTP listener disabled!")
|
||||
return nil
|
||||
}
|
||||
u.Logf("Prometheus is enabled")
|
||||
|
||||
u.Namespace = strings.Trim(strings.ReplaceAll(u.Namespace, "-", "_"), "_")
|
||||
if u.Namespace == "" {
|
||||
|
|
|
|||
|
|
@ -73,9 +73,6 @@ func (s *Server) Enabled() bool {
|
|||
if s.Config == nil {
|
||||
return false
|
||||
}
|
||||
if s.Collect == nil {
|
||||
return false
|
||||
}
|
||||
return s.Enable
|
||||
}
|
||||
|
||||
|
|
@ -83,9 +80,10 @@ func (s *Server) Enabled() bool {
|
|||
func (s *Server) Run(c poller.Collect) error {
|
||||
s.Collect = c
|
||||
if s.Config == nil || s.Port == 0 || s.HTMLPath == "" || !s.Enabled() {
|
||||
s.Logf("Internal web server disabled!")
|
||||
s.LogDebugf("Internal web server disabled!")
|
||||
return nil
|
||||
}
|
||||
s.Logf("Internal web server enabled")
|
||||
|
||||
if _, err := os.Stat(s.HTMLPath); err != nil {
|
||||
return fmt.Errorf("problem with HTML path: %w", err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue