Skip to content

Commit

Permalink
disable check
Browse files Browse the repository at this point in the history
  • Loading branch information
platinummonkey committed Nov 24, 2022
1 parent 1571c63 commit 8037ce3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 8037ce3

Please sign in to comment.