diff options
Diffstat (limited to 'src/go/plugin/go.d/modules/unbound')
-rw-r--r-- | src/go/plugin/go.d/modules/unbound/init.go | 8 | ||||
-rw-r--r-- | src/go/plugin/go.d/modules/unbound/integrations/unbound.md | 4 | ||||
-rw-r--r-- | src/go/plugin/go.d/modules/unbound/unbound.go | 21 | ||||
-rw-r--r-- | src/go/plugin/go.d/modules/unbound/unbound_test.go | 22 |
4 files changed, 19 insertions, 36 deletions
diff --git a/src/go/plugin/go.d/modules/unbound/init.go b/src/go/plugin/go.d/modules/unbound/init.go index 88e5e5ab..6895ce42 100644 --- a/src/go/plugin/go.d/modules/unbound/init.go +++ b/src/go/plugin/go.d/modules/unbound/init.go @@ -86,11 +86,9 @@ func (u *Unbound) initClient() (err error) { } u.client = socket.New(socket.Config{ - Address: u.Address, - ConnectTimeout: u.Timeout.Duration(), - ReadTimeout: u.Timeout.Duration(), - WriteTimeout: u.Timeout.Duration(), - TLSConf: tlsCfg, + Address: u.Address, + Timeout: u.Timeout.Duration(), + TLSConf: tlsCfg, }) return nil } diff --git a/src/go/plugin/go.d/modules/unbound/integrations/unbound.md b/src/go/plugin/go.d/modules/unbound/integrations/unbound.md index df641227..18a09c21 100644 --- a/src/go/plugin/go.d/modules/unbound/integrations/unbound.md +++ b/src/go/plugin/go.d/modules/unbound/integrations/unbound.md @@ -159,8 +159,8 @@ For auto-detection parameters from `unbound.conf`: The configuration file name for this integration is `go.d/unbound.conf`. -You can edit the configuration file using the `edit-config` script from the -Netdata [config directory](/docs/netdata-agent/configuration/README.md#the-netdata-config-directory). +You can edit the configuration file using the [`edit-config`](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#edit-a-configuration-file-using-edit-config) script from the +Netdata [config directory](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration/README.md#the-netdata-config-directory). ```bash cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata diff --git a/src/go/plugin/go.d/modules/unbound/unbound.go b/src/go/plugin/go.d/modules/unbound/unbound.go index fa071bb0..d15e6fce 100644 --- a/src/go/plugin/go.d/modules/unbound/unbound.go +++ b/src/go/plugin/go.d/modules/unbound/unbound.go @@ -5,12 +5,13 @@ package unbound import ( _ "embed" "errors" + "fmt" "time" "github.com/netdata/netdata/go/plugins/plugin/go.d/agent/module" + "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/confopt" "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/socket" "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/tlscfg" - "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/web" ) //go:embed "config_schema.json" @@ -29,7 +30,7 @@ func New() *Unbound { Config: Config{ Address: "127.0.0.1:8953", ConfPath: "/etc/unbound/unbound.conf", - Timeout: web.Duration(time.Second), + Timeout: confopt.Duration(time.Second), Cumulative: false, UseTLS: true, TLSConfig: tlscfg.TLSConfig{ @@ -44,12 +45,12 @@ func New() *Unbound { } type Config struct { - UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"` - Address string `yaml:"address" json:"address"` - ConfPath string `yaml:"conf_path,omitempty" json:"conf_path"` - Timeout web.Duration `yaml:"timeout,omitempty" json:"timeout"` - Cumulative bool `yaml:"cumulative_stats" json:"cumulative_stats"` - UseTLS bool `yaml:"use_tls,omitempty" json:"use_tls"` + UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"` + Address string `yaml:"address" json:"address"` + ConfPath string `yaml:"conf_path,omitempty" json:"conf_path"` + Timeout confopt.Duration `yaml:"timeout,omitempty" json:"timeout"` + Cumulative bool `yaml:"cumulative_stats" json:"cumulative_stats"` + UseTLS bool `yaml:"use_tls,omitempty" json:"use_tls"` tlscfg.TLSConfig `yaml:",inline" json:""` } @@ -77,8 +78,7 @@ func (u *Unbound) Init() error { } if err := u.initClient(); err != nil { - u.Errorf("creating client: %v", err) - return err + return fmt.Errorf("creating client: %v", err) } u.charts = charts(u.Cumulative) @@ -94,7 +94,6 @@ func (u *Unbound) Init() error { func (u *Unbound) Check() error { mx, err := u.collect() if err != nil { - u.Error(err) return err } if len(mx) == 0 { diff --git a/src/go/plugin/go.d/modules/unbound/unbound_test.go b/src/go/plugin/go.d/modules/unbound/unbound_test.go index f9ed73af..e23147cd 100644 --- a/src/go/plugin/go.d/modules/unbound/unbound_test.go +++ b/src/go/plugin/go.d/modules/unbound/unbound_test.go @@ -269,11 +269,13 @@ func (m mockUnboundClient) Command(_ string, process socket.Processor) error { return nil } -func testCharts(t *testing.T, unbound *Unbound, collected map[string]int64) { +func testCharts(t *testing.T, unbound *Unbound, mx map[string]int64) { t.Helper() ensureChartsCreatedForEveryThread(t, unbound) ensureExtendedChartsCreated(t, unbound) - ensureCollectedHasAllChartsDimsVarsIDs(t, unbound, collected) + module.TestMetricsHasAllChartsDimsSkip(t, unbound.Charts(), mx, func(_ *module.Chart, dim *module.Dim) bool { + return dim.ID == "mem.mod.ipsecmod" + }) } func ensureChartsCreatedForEveryThread(t *testing.T, u *Unbound) { @@ -318,22 +320,6 @@ func ensureExtendedChartsCreated(t *testing.T, u *Unbound) { } } -func ensureCollectedHasAllChartsDimsVarsIDs(t *testing.T, u *Unbound, collected map[string]int64) { - for _, chart := range *u.Charts() { - for _, dim := range chart.Dims { - if dim.ID == "mem.mod.ipsecmod" { - continue - } - _, ok := collected[dim.ID] - assert.Truef(t, ok, "collected metrics has no data for dim '%s' chart '%s'", dim.ID, chart.ID) - } - for _, v := range chart.Vars { - _, ok := collected[v.ID] - assert.Truef(t, ok, "collected metrics has no data for var '%s' chart '%s'", v.ID, chart.ID) - } - } -} - var ( expectedCommon = map[string]int64{ "thread0.num.cachehits": 21, |