summaryrefslogtreecommitdiffstats
path: root/src/go/plugin/go.d/modules/freeradius
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-09 08:36:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-09 08:36:07 +0000
commite8c44275b9a1937b5948010a042294d580d36d7c (patch)
treee87c73e25556c3c9d5442f5ca4ba0cf46c64ec70 /src/go/plugin/go.d/modules/freeradius
parentAdding upstream version 1.47.5. (diff)
downloadnetdata-upstream.tar.xz
netdata-upstream.zip
Adding upstream version 2.0.0.upstream/2.0.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/go/plugin/go.d/modules/freeradius')
-rw-r--r--src/go/plugin/go.d/modules/freeradius/freeradius.go19
-rw-r--r--src/go/plugin/go.d/modules/freeradius/freeradius_test.go19
-rw-r--r--src/go/plugin/go.d/modules/freeradius/integrations/freeradius.md4
3 files changed, 14 insertions, 28 deletions
diff --git a/src/go/plugin/go.d/modules/freeradius/freeradius.go b/src/go/plugin/go.d/modules/freeradius/freeradius.go
index e3c995b5..46aa0619 100644
--- a/src/go/plugin/go.d/modules/freeradius/freeradius.go
+++ b/src/go/plugin/go.d/modules/freeradius/freeradius.go
@@ -5,11 +5,12 @@ package freeradius
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/modules/freeradius/api"
- "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/web"
+ "github.com/netdata/netdata/go/plugins/plugin/go.d/pkg/confopt"
)
//go:embed "config_schema.json"
@@ -29,17 +30,17 @@ func New() *FreeRADIUS {
Address: "127.0.0.1",
Port: 18121,
Secret: "adminsecret",
- Timeout: web.Duration(time.Second),
+ Timeout: confopt.Duration(time.Second),
},
}
}
type Config struct {
- UpdateEvery int `yaml:"update_every" json:"update_every"`
- Address string `yaml:"address" json:"address"`
- Port int `yaml:"port" json:"port"`
- Secret string `yaml:"secret" json:"secret"`
- Timeout web.Duration `yaml:"timeout" json:"timeout"`
+ UpdateEvery int `yaml:"update_every" json:"update_every"`
+ Address string `yaml:"address" json:"address"`
+ Port int `yaml:"port" json:"port"`
+ Secret string `yaml:"secret" json:"secret"`
+ Timeout confopt.Duration `yaml:"timeout" json:"timeout"`
}
type (
@@ -60,8 +61,7 @@ func (f *FreeRADIUS) Configuration() any {
func (f *FreeRADIUS) Init() error {
if err := f.validateConfig(); err != nil {
- f.Errorf("config validation: %v", err)
- return err
+ return fmt.Errorf("config validation: %v", err)
}
f.client = api.New(api.Config{
@@ -77,7 +77,6 @@ func (f *FreeRADIUS) Init() error {
func (f *FreeRADIUS) Check() error {
mx, err := f.collect()
if err != nil {
- f.Error(err)
return err
}
if len(mx) == 0 {
diff --git a/src/go/plugin/go.d/modules/freeradius/freeradius_test.go b/src/go/plugin/go.d/modules/freeradius/freeradius_test.go
index 58e2dce5..21ad2551 100644
--- a/src/go/plugin/go.d/modules/freeradius/freeradius_test.go
+++ b/src/go/plugin/go.d/modules/freeradius/freeradius_test.go
@@ -117,10 +117,10 @@ func TestFreeRADIUS_Collect(t *testing.T) {
"proxy-acct-dropped-requests": 33,
"proxy-acct-unknown-types": 34,
}
- collected := freeRADIUS.Collect()
+ mx := freeRADIUS.Collect()
- assert.Equal(t, expected, collected)
- ensureCollectedHasAllChartsDimsVarsIDs(t, freeRADIUS, collected)
+ assert.Equal(t, expected, mx)
+ module.TestMetricsHasAllChartsDims(t, freeRADIUS.Charts(), mx)
}
func TestFreeRADIUS_Collect_ReturnsNilIfClientStatusReturnsError(t *testing.T) {
@@ -134,19 +134,6 @@ func TestFreeRADIUS_Cleanup(t *testing.T) {
New().Cleanup()
}
-func ensureCollectedHasAllChartsDimsVarsIDs(t *testing.T, f *FreeRADIUS, collected map[string]int64) {
- for _, chart := range *f.Charts() {
- for _, dim := range chart.Dims {
- _, 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)
- }
- }
-}
-
func newOKMockClient() *mockClient {
return &mockClient{}
}
diff --git a/src/go/plugin/go.d/modules/freeradius/integrations/freeradius.md b/src/go/plugin/go.d/modules/freeradius/integrations/freeradius.md
index 59b124f7..57f5a565 100644
--- a/src/go/plugin/go.d/modules/freeradius/integrations/freeradius.md
+++ b/src/go/plugin/go.d/modules/freeradius/integrations/freeradius.md
@@ -102,8 +102,8 @@ To enable status server, follow the [official documentation](https://wiki.freera
The configuration file name for this integration is `go.d/freeradius.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