disable check

This commit is contained in:
Cody Lee 2022-11-23 19:15:55 -06:00
parent 8f3e94758a
commit 47bdfa7bec
1 changed files with 4 additions and 3 deletions

View File

@ -28,7 +28,7 @@ type Config struct {
DeadPorts bool `json:"dead_ports,omitempty" toml:"dead_ports,omitempty" xml:"dead_ports,omitempty" yaml:"dead_ports,omitempty"`
// Disable when true disables this output plugin
Disable bool `json:"disable" toml:"disable" xml:"disable,attr" yaml:"disable"`
Disable *bool `json:"disable" toml:"disable" xml:"disable,attr" yaml:"disable"`
// Address determines how to talk to the Datadog agent
Address string `json:"address" toml:"address" xml:"address,attr" yaml:"address"`
@ -191,11 +191,12 @@ func (u *DatadogUnifi) setConfigDefaults() {
// Run runs a ticker to poll the unifi server and update Datadog.
func (u *DatadogUnifi) Run(c poller.Collect) error {
u.Collector = c
if u.Disable {
disabled := u.Disable == nil || *u.Disable == true
if disabled {
u.LogDebugf("Datadog config is disabled, output is disabled.")
return nil
}
if u.Config == nil && !u.Disable {
if u.Config == nil && !disabled {
u.LogErrorf("DataDog config is missing and is not disabled: Datadog output is disabled!")
return nil
}