Remove max errors parameter
This commit is contained in:
parent
4117da25cd
commit
bdfec45579
|
|
@ -101,18 +101,6 @@ is provided so the application can be easily adapted to any environment.
|
||||||
This mode can also be combined with a "test database" in InfluxDB to
|
This mode can also be combined with a "test database" in InfluxDB to
|
||||||
give yourself a "test config file" you may run ad-hoc to test changes.
|
give yourself a "test config file" you may run ad-hoc to test changes.
|
||||||
|
|
||||||
max_errors default: 0
|
|
||||||
If you restart the UniFI controller, the poller will lose access until
|
|
||||||
it is restarted. Specifying a number greater than -1 for max_errors will
|
|
||||||
cause the poller to exit when it reaches the error count specified.
|
|
||||||
This problematic condition can be triggered by InfluxDB having issues
|
|
||||||
too. Generally only 1 error per interval is created, but if more than one
|
|
||||||
backend is having issues > 1 error could be generated per interval. Once
|
|
||||||
the poller exits, it is expected that something will restart it
|
|
||||||
automatically so it gets back in line; something is usually systemd,
|
|
||||||
docker or launchd. The default setting of 0 will cause an exit after
|
|
||||||
just 1 error. Recommended values are 0-5.
|
|
||||||
|
|
||||||
influx_url default: http://127.0.0.1:8086
|
influx_url default: http://127.0.0.1:8086
|
||||||
This is the URL where the Influx web server is available.
|
This is the URL where the Influx web server is available.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,6 @@ quiet = false
|
||||||
# or a simple crontab to keep the timings accurate on UniFi Poller run intervals.
|
# or a simple crontab to keep the timings accurate on UniFi Poller run intervals.
|
||||||
mode = "influx"
|
mode = "influx"
|
||||||
|
|
||||||
# If the poller experiences an error from the UniFi controller or from InfluxDB
|
|
||||||
# it will exit. If you do not want it to exit, change max_errors to -1. You can
|
|
||||||
# adjust the config to tolerate more errors by setting this to a higher value.
|
|
||||||
# Recommend setting this between 0 and 5. See man page for more explanation.
|
|
||||||
max_errors = 0
|
|
||||||
|
|
||||||
# InfluxDB does not require auth by default, so the user/password are probably unimportant.
|
# InfluxDB does not require auth by default, so the user/password are probably unimportant.
|
||||||
influx_url = "http://127.0.0.1:8086"
|
influx_url = "http://127.0.0.1:8086"
|
||||||
influx_user = "unifi"
|
influx_user = "unifi"
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
"debug": false,
|
"debug": false,
|
||||||
"quiet": false,
|
"quiet": false,
|
||||||
"mode": "influx",
|
"mode": "influx",
|
||||||
"max_errors": 0,
|
|
||||||
"influx_url": "http://127.0.0.1:8086",
|
"influx_url": "http://127.0.0.1:8086",
|
||||||
"influx_user": "unifi",
|
"influx_user": "unifi",
|
||||||
"influx_pass": "unifi",
|
"influx_pass": "unifi",
|
||||||
|
|
|
||||||
|
|
@ -48,14 +48,6 @@
|
||||||
-->
|
-->
|
||||||
<mode>influx</mode>
|
<mode>influx</mode>
|
||||||
|
|
||||||
<!--
|
|
||||||
# If the poller experiences an error from the UniFi controller or from InfluxDB
|
|
||||||
# it will exit. If you do not want it to exit, change max_errors to -1. You can
|
|
||||||
# adjust the config to tolerate more errors by setting this to a higher value.
|
|
||||||
# Recommend setting this between 0 and 5. See man page for more explanation.
|
|
||||||
-->
|
|
||||||
<max_errors>0</max_errors>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
# InfluxDB does not require auth by default, so the user/password are probably unimportant.
|
# InfluxDB does not require auth by default, so the user/password are probably unimportant.
|
||||||
-->
|
-->
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,6 @@ quiet: false
|
||||||
# or a simple crontab to keep the timings accurate on UniFi Poller run intervals.
|
# or a simple crontab to keep the timings accurate on UniFi Poller run intervals.
|
||||||
mode: "influx"
|
mode: "influx"
|
||||||
|
|
||||||
# If the poller experiences an error from the UniFi controller or from InfluxDB
|
|
||||||
# it will exit. If you do not want it to exit, change max_errors to -1. You can
|
|
||||||
# adjust the config to tolerate more errors by setting this to a higher value.
|
|
||||||
# Recommend setting this between 0 and 5. See man page for more explanation.
|
|
||||||
max_errors: 0
|
|
||||||
|
|
||||||
# InfluxDB does not require auth by default, so the user/password are probably unimportant.
|
# InfluxDB does not require auth by default, so the user/password are probably unimportant.
|
||||||
influx_url: "http://127.0.0.1:8086"
|
influx_url: "http://127.0.0.1:8086"
|
||||||
influx_user: "unifi"
|
influx_user: "unifi"
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,6 @@ type Metrics struct {
|
||||||
// This is all of the data stored in the config file.
|
// This is all of the data stored in the config file.
|
||||||
// Any with explicit defaults have _omitempty on json and toml tags.
|
// Any with explicit defaults have _omitempty on json and toml tags.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
MaxErrors int `json:"max_errors" toml:"max_errors" xml:"max_errors" yaml:"max_errors" env:"MAX_ERRORS"`
|
|
||||||
Interval Duration `json:"interval,_omitempty" toml:"interval,_omitempty" xml:"interval" yaml:"interval" env:"POLLING_INTERVAL"`
|
Interval Duration `json:"interval,_omitempty" toml:"interval,_omitempty" xml:"interval" yaml:"interval" env:"POLLING_INTERVAL"`
|
||||||
Debug bool `json:"debug" toml:"debug" xml:"debug" yaml:"debug" env:"DEBUG_MODE"`
|
Debug bool `json:"debug" toml:"debug" xml:"debug" yaml:"debug" env:"DEBUG_MODE"`
|
||||||
Quiet bool `json:"quiet,_omitempty" toml:"quiet,_omitempty" xml:"quiet" yaml:"quiet" env:"QUIET_MODE"`
|
Quiet bool `json:"quiet,_omitempty" toml:"quiet,_omitempty" xml:"quiet" yaml:"quiet" env:"QUIET_MODE"`
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
func (u *UnifiPoller) LogError(err error, prefix string) {
|
func (u *UnifiPoller) LogError(err error, prefix string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
u.errorCount++
|
u.errorCount++
|
||||||
_ = log.Output(2, fmt.Sprintf("[ERROR] (%v/%v) %v: %v", u.errorCount, u.Config.MaxErrors, prefix, err))
|
_ = log.Output(2, fmt.Sprintf("[ERROR] %v: %v", prefix, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,8 @@ func (u *UnifiPoller) PollController() error {
|
||||||
// Only run this if the authentication procedure didn't return error.
|
// Only run this if the authentication procedure didn't return error.
|
||||||
_ = u.CollectAndReport()
|
_ = u.CollectAndReport()
|
||||||
}
|
}
|
||||||
if u.Config.MaxErrors >= 0 && u.errorCount > u.Config.MaxErrors {
|
if u.errorCount > 0 {
|
||||||
return fmt.Errorf("reached maximum error count, stopping poller (%d > %d)",
|
return fmt.Errorf("controller or influxdb errors, stopping poller")
|
||||||
u.errorCount, u.Config.MaxErrors)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue