chore(go.d/ddsmp): profile definition cleanup (#21062)
Ilya Mashchenko committed
Sep 27, 2025 at 16:07 UTC
c2b4ad5209571285932d811d296e962e77171b06
26 files changed
+412
-1204
src/go/go.mod
+1
-5
@@ -29,7 +29,6 @@ require (
29
github.com/google/uuid v1.6.0
30
github.com/gorcon/rcon v1.4.0
31
github.com/gosnmp/gosnmp v1.42.1
32
- github.com/invopop/jsonschema v0.13.0
32
github.com/jackc/pgx/v4 v4.18.3
33
github.com/jackc/pgx/v5 v5.7.6
34
github.com/jessevdk/go-flags v1.6.1
@@ -54,6 +53,7 @@ require (
53
go.mongodb.org/mongo-driver v1.17.4
54
go.uber.org/automaxprocs v1.6.0
55
golang.org/x/net v0.44.0
56
+ golang.org/x/sync v0.17.0
57
golang.org/x/text v0.29.0
58
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220504211119-3d4a969bb56b
59
gopkg.in/ini.v1 v1.67.0
@@ -73,8 +73,6 @@ require (
73
github.com/Masterminds/goutils v1.1.1 // indirect
74
github.com/Masterminds/semver/v3 v3.3.0 // indirect
75
github.com/Microsoft/go-winio v0.6.1 // indirect
76
- github.com/bahlo/generic-list-go v0.2.0 // indirect
77
- github.com/buger/jsonparser v1.1.1 // indirect
76
github.com/cespare/xxhash/v2 v2.3.0 // indirect
77
github.com/containerd/errdefs v1.0.0 // indirect
78
github.com/containerd/errdefs/pkg v0.3.0 // indirect
@@ -142,7 +140,6 @@ require (
140
github.com/spf13/pflag v1.0.6 // indirect
141
github.com/tidwall/match v1.1.1 // indirect
142
github.com/tidwall/pretty v1.2.0 // indirect
145
- github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
143
github.com/x448/float16 v0.8.4 // indirect
144
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
145
github.com/xdg-go/scram v1.1.2 // indirect
@@ -159,7 +156,6 @@ require (
156
golang.org/x/crypto v0.42.0 // indirect
157
golang.org/x/mod v0.27.0 // indirect
158
golang.org/x/oauth2 v0.30.0 // indirect
162
- golang.org/x/sync v0.17.0 // indirect
159
golang.org/x/sys v0.36.0 // indirect
160
golang.org/x/term v0.35.0 // indirect
161
golang.org/x/time v0.9.0 // indirect
src/go/go.sum
-8
@@ -45,8 +45,6 @@ github.com/aws/aws-sdk-go v1.55.6 h1:cSg4pvZ3m8dgYcgqB97MrcdjUmZ1BeMYKUxMMB89IPk
45
github.com/aws/aws-sdk-go v1.55.6/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
46
github.com/axiomhq/hyperloglog v0.2.5 h1:Hefy3i8nAs8zAI/tDp+wE7N+Ltr8JnwiW3875pvl0N8=
47
github.com/axiomhq/hyperloglog v0.2.5/go.mod h1:DLUK9yIzpU5B6YFLjxTIcbHu1g4Y1WQb1m5RH3radaM=
48
-github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
49
-github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
48
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
49
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
50
github.com/bitly/go-hostpool v0.1.0 h1:XKmsF6k5el6xHG3WPJ8U0Ku/ye7njX7W81Ng7O2ioR0=
@@ -61,8 +59,6 @@ github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
59
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
60
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
61
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
64
-github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
65
-github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
62
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
63
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
64
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
@@ -190,8 +186,6 @@ github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI
186
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
187
github.com/ilyam8/gosnmp v0.0.0-20250912202722-388b2cb5192e h1:3f1r8AJrTdUWUVa4H4tRYmJAEEmnsU5COu4ycVOCAjo=
188
github.com/ilyam8/gosnmp v0.0.0-20250912202722-388b2cb5192e/go.mod h1:CxVS6bXqmWZlafUj9pZUnQX5e4fAltqPcijxWpCitDo=
193
-github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E=
194
-github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0=
189
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
190
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
191
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
@@ -442,8 +436,6 @@ github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXV
436
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
437
github.com/vmware/govmomi v0.52.0 h1:JyxQ1IQdllrY7PJbv2am9mRsv3p9xWlIQ66bv+XnyLw=
438
github.com/vmware/govmomi v0.52.0/go.mod h1:Yuc9xjznU3BH0rr6g7MNS1QGvxnJlE1vOvTJ7Lx7dqI=
445
-github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
446
-github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
439
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
440
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
441
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/README.md
deleted
-9
@@ -1,9 +0,0 @@
1
-
2
-# Generate Json Schema
3
-
4
-```
5
-cd pkg/networkdevice/profile/profiledefinition/schema_cmd
6
-go generate
7
-```
8
-
9
-The command above will generate this jsonschema file `profiledefinition/schema/profile_rc_schema.json`.
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/bundle.go
deleted
-17
@@ -1,17 +0,0 @@
1
-// Unless explicitly stated otherwise all files in this repository are licensed
2
-// under the Apache License Version 2.0.
3
-// This product includes software developed at Datadog (https://www.datadoghq.com/).
4
-// Copyright 2023-present Datadog, Inc.
5
-
6
-package ddprofiledefinition
7
-
8
-// ProfileBundleProfileItem represent a profile entry with metadata.
9
-type ProfileBundleProfileItem struct {
10
- Profile ProfileDefinition `json:"profile"`
11
-}
12
-
13
-// ProfileBundle represent a list of profiles meant to be downloaded by user.
14
-type ProfileBundle struct {
15
- CreatedTimestamp int64 `json:"created_timestamp"` // Millisecond
16
- Profiles []ProfileBundleProfileItem `json:"profiles"`
17
-}
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/clone.go
+5
-5
@@ -5,15 +5,15 @@
5
6
package ddprofiledefinition
7
8
-// Cloneable is a generic type for objects that can duplicate themselves.
9
-// It is exclusively used in the form [T Cloneable[T]], i.e. a type that
8
+// cloneable is a generic type for objects that can duplicate themselves.
9
+// It is exclusively used in the form [T cloneable[T]], i.e. a type that
10
// has a .Clone() that returns a new instance of itself.
11
-type Cloneable[T any] interface {
11
+type cloneable[T any] interface {
12
Clone() T
13
}
14
15
// CloneSlice clones all the objects in a slice into a new slice.
16
-func CloneSlice[Slice ~[]T, T Cloneable[T]](s Slice) Slice {
16
+func cloneSlice[Slice ~[]T, T cloneable[T]](s Slice) Slice {
17
if s == nil {
18
return nil
19
}
@@ -26,7 +26,7 @@ func CloneSlice[Slice ~[]T, T Cloneable[T]](s Slice) Slice {
26
27
// CloneMap clones a map[K]T for any cloneable type T.
28
// The map keys are shallow-copied; values are cloned.
29
-func CloneMap[Map ~map[K]T, K comparable, T Cloneable[T]](m Map) Map {
29
+func cloneMap[Map ~map[K]T, K comparable, T cloneable[T]](m Map) Map {
30
if m == nil {
31
return nil
32
}
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/clone_test.go
+4
-4
@@ -40,7 +40,7 @@ func TestCloneSlice(t *testing.T) {
40
item("a", 1, 2, 3, 4),
41
item("b", 1, 2),
42
}
43
- itemsCopy := CloneSlice(items)
43
+ itemsCopy := cloneSlice(items)
44
*itemsCopy[0].label = "aaa"
45
itemsCopy[1] = item("bbb", 10, 20)
46
itemsCopy = append(itemsCopy, item("ccc", 100, 200))
@@ -61,7 +61,7 @@ func TestCloneMap(t *testing.T) {
61
"Item A": item("a", 1, 2, 3, 4),
62
"Item B": item("b", 1, 2),
63
}
64
- mCopy := CloneMap(m)
64
+ mCopy := cloneMap(m)
65
mCopy["Item A"].ps[0] = 100
66
mCopy["Item B"] = item("bbb", 10, 20)
67
mCopy["Item C"] = item("ccc", 100, 200)
@@ -83,7 +83,7 @@ func TestCustomSliceClone(t *testing.T) {
83
item("a", 1, 2, 3, 4),
84
item("b", 1, 2),
85
}
86
- itemsCopy := CloneSlice(items)
86
+ itemsCopy := cloneSlice(items)
87
88
assert.IsType(t, customSlice{}, itemsCopy)
89
assert.Equal(t, items, itemsCopy)
@@ -96,7 +96,7 @@ func TestCustomMapClone(t *testing.T) {
96
"Item A": item("a", 1, 2, 3, 4),
97
"Item B": item("b", 1, 2),
98
}
99
- mCopy := CloneMap(m)
99
+ mCopy := cloneMap(m)
100
assert.IsType(t, customMap{}, mCopy)
101
assert.Equal(t, m, mCopy)
102
}
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/doc.go
deleted
-7
@@ -1,7 +0,0 @@
1
-// Unless explicitly stated otherwise all files in this repository are licensed
2
-// under the Apache License Version 2.0.
3
-// This product includes software developed at Datadog (https://www.datadoghq.com/).
4
-// Copyright 2023-present Datadog, Inc.
5
-
6
-// Package profiledefinition contain the structure used to parse SNMP Profiles
7
-package ddprofiledefinition
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/listmap.go
deleted
-56
@@ -1,56 +0,0 @@
1
-// Unless explicitly stated otherwise all files in this repository are licensed
2
-// under the Apache License Version 2.0.
3
-// This product includes software developed at Datadog (https://www.datadoghq.com/).
4
-// Copyright 2023-present Datadog, Inc.
5
-
6
-package ddprofiledefinition
7
-
8
-import (
9
- "encoding/json"
10
-
11
- "github.com/invopop/jsonschema"
12
-)
13
-
14
-// ListMap is used to marshall a map into a list (map[string]T to []MapItem[T]) and vice versa.
15
-type ListMap[T any] map[string]T
16
-
17
-// MapItem is used for ListMap marshalling/unmarshalling
18
-type MapItem[T any] struct {
19
- Key string `json:"key"`
20
- Value T `json:"value"`
21
-}
22
-
23
-// MarshalJSON marshalls map to list
24
-func (lm ListMap[T]) MarshalJSON() ([]byte, error) {
25
- var items []MapItem[T]
26
- for key, value := range lm {
27
- items = append(items, MapItem[T]{Key: key, Value: value})
28
- }
29
- return json.Marshal(items)
30
-}
31
-
32
-// UnmarshalJSON unmarshalls list to map
33
-func (lm *ListMap[T]) UnmarshalJSON(data []byte) error {
34
- var items []MapItem[T]
35
- if err := json.Unmarshal(data, &items); err != nil {
36
- return err
37
- }
38
- result := make(ListMap[T])
39
- for _, item := range items {
40
- result[item.Key] = item.Value
41
- }
42
- *lm = result
43
- return nil
44
-}
45
-
46
-// JSONSchema is needed to customize jsonschema to match []MapItem[T] used in json format
47
-func (lm ListMap[T]) JSONSchema() *jsonschema.Schema {
48
- reflector := jsonschema.Reflector{
49
- AllowAdditionalProperties: false,
50
- DoNotReference: true,
51
- }
52
- schema := reflector.Reflect([]MapItem[T]{})
53
- // don't need version because this is a child of a versioned schema.
54
- schema.Version = ""
55
- return schema
56
-}
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/listmap_test.go
deleted
-103
@@ -1,103 +0,0 @@
1
-// Unless explicitly stated otherwise all files in this repository are licensed
2
-// under the Apache License Version 2.0.
3
-// This product includes software developed at Datadog (https://www.datadoghq.com/).
4
-// Copyright 2023-present Datadog, Inc.
5
-
6
-package ddprofiledefinition
7
-
8
-import (
9
- "encoding/json"
10
- "testing"
11
-
12
- "github.com/invopop/jsonschema"
13
- "github.com/stretchr/testify/assert"
14
- "github.com/stretchr/testify/require"
15
-)
16
-
17
-type ExampleStruct struct {
18
- Mapping ListMap[string] `json:"mapping"`
19
-}
20
-
21
-var example = ExampleStruct{
22
- Mapping: map[string]string{
23
- "1": "aaa",
24
- "2": "bbb",
25
- },
26
-}
27
-
28
-var exampleJSON = `{
29
- "mapping": [
30
- {"key": "2", "value": "bbb"},
31
- {"key": "1", "value": "aaa"}
32
- ]
33
-}`
34
-
35
-func TestListMap_MarshalJSON(t *testing.T) {
36
- bytes, err := json.Marshal(example)
37
- require.NoError(t, err)
38
-
39
- var expectedExample ExampleStruct
40
- err = json.Unmarshal(bytes, &expectedExample)
41
- require.NoError(t, err)
42
-
43
- assert.Equal(t, example.Mapping, expectedExample.Mapping)
44
-}
45
-
46
-func TestListMap_UnmarshalJSON(t *testing.T) {
47
- var expectedExample ExampleStruct
48
- err := json.Unmarshal([]byte(exampleJSON), &expectedExample)
49
- require.NoError(t, err)
50
-
51
- assert.Equal(t, example.Mapping, expectedExample.Mapping)
52
-}
53
-
54
-func TestListMap_JSONSchema(t *testing.T) {
55
- reflector := jsonschema.Reflector{
56
- AllowAdditionalProperties: false,
57
- }
58
- schema := reflector.Reflect(&ExampleStruct{})
59
- schema.Version = "" // no version, to make the test more future-proof
60
- schemaJSON, err := json.MarshalIndent(schema, "", " ")
61
- require.NoError(t, err)
62
-
63
- expectedSchema := `
64
-{
65
- "$id": "https://github.com/netdata/netdata/go/plugins/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/example-struct",
66
- "$ref": "#/$defs/ExampleStruct",
67
- "$defs": {
68
- "ExampleStruct": {
69
- "properties": {
70
- "mapping": {
71
- "$ref": "#/$defs/ListMap[string]"
72
- }
73
- },
74
- "additionalProperties": false,
75
- "type": "object",
76
- "required": [
77
- "mapping"
78
- ]
79
- },
80
- "ListMap[string]": {
81
- "items": {
82
- "properties": {
83
- "key": {
84
- "type": "string"
85
- },
86
- "value": {
87
- "type": "string"
88
- }
89
- },
90
- "additionalProperties": false,
91
- "type": "object",
92
- "required": [
93
- "key",
94
- "value"
95
- ]
96
- },
97
- "type": "array"
98
- }
99
- }
100
-}
101
-`
102
- assert.JSONEq(t, expectedSchema, string(schemaJSON))
103
-}
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/metadata.go
+10
-38
@@ -5,45 +5,28 @@
5
6
package ddprofiledefinition
7
8
-import "github.com/invopop/jsonschema"
9
-
8
// MetadataDeviceResource is the device resource name
9
const MetadataDeviceResource = "device"
10
11
// MetadataConfig holds configs per resource type
14
-type MetadataConfig ListMap[MetadataResourceConfig]
15
-
16
-// JSONSchema defines the JSON schema for MetadataConfig
17
-func (mc MetadataConfig) JSONSchema() *jsonschema.Schema {
18
- return ListMap[MetadataResourceConfig](mc).JSONSchema()
19
-}
20
-
21
-// MarshalJSON marshals the metadata config
22
-func (mc MetadataConfig) MarshalJSON() ([]byte, error) {
23
- return ListMap[MetadataResourceConfig](mc).MarshalJSON()
24
-}
25
-
26
-// UnmarshalJSON unmarshals the metadata config
27
-func (mc *MetadataConfig) UnmarshalJSON(data []byte) error {
28
- return (*ListMap[MetadataResourceConfig])(mc).UnmarshalJSON(data)
29
-}
12
+type MetadataConfig map[string]MetadataResourceConfig
13
14
// Clone duplicates this MetadataConfig
15
func (mc MetadataConfig) Clone() MetadataConfig {
33
- return CloneMap(mc)
16
+ return cloneMap(mc)
17
}
18
19
// MetadataResourceConfig holds configs for a metadata resource
20
type MetadataResourceConfig struct {
38
- Fields ListMap[MetadataField] `yaml:"fields" json:"fields"`
39
- IDTags MetricTagConfigList `yaml:"id_tags,omitempty" json:"id_tags,omitempty"`
21
+ Fields map[string]MetadataField `yaml:"fields" json:"fields"`
22
+ IDTags MetricTagConfigList `yaml:"id_tags,omitempty" json:"id_tags,omitempty"`
23
}
24
25
// Clone duplicates this MetadataResourceConfig
26
func (c MetadataResourceConfig) Clone() MetadataResourceConfig {
27
return MetadataResourceConfig{
45
- Fields: CloneMap(c.Fields),
46
- IDTags: CloneSlice(c.IDTags),
28
+ Fields: cloneMap(c.Fields),
29
+ IDTags: cloneSlice(c.IDTags),
30
}
31
}
32
@@ -58,30 +41,19 @@ type MetadataField struct {
41
func (c MetadataField) Clone() MetadataField {
42
return MetadataField{
43
Symbol: c.Symbol.Clone(),
61
- Symbols: CloneSlice(c.Symbols),
44
+ Symbols: cloneSlice(c.Symbols),
45
Value: c.Value,
46
}
47
}
48
66
-// NewMetadataResourceConfig returns a new metadata resource config
67
-func NewMetadataResourceConfig() MetadataResourceConfig {
68
- return MetadataResourceConfig{}
69
-}
70
-
71
-// IsMetadataResourceWithScalarOids returns true if the resource is based on scalar OIDs
72
-// at the moment, we only expect "device" resource to be based on scalar OIDs
73
-func IsMetadataResourceWithScalarOids(resource string) bool {
74
- return resource == MetadataDeviceResource
75
-}
76
-
49
type SysobjectIDMetadataEntryConfig struct {
78
- SysobjectID string `yaml:"sysobjectid"`
79
- Metadata ListMap[MetadataField] `yaml:"metadata"`
50
+ SysobjectID string `yaml:"sysobjectid"`
51
+ Metadata map[string]MetadataField `yaml:"metadata"`
52
}
53
54
func (e SysobjectIDMetadataEntryConfig) Clone() SysobjectIDMetadataEntryConfig {
55
return SysobjectIDMetadataEntryConfig{
56
SysobjectID: e.SysobjectID,
85
- Metadata: CloneMap(e.Metadata),
57
+ Metadata: cloneMap(e.Metadata),
58
}
59
}
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/metrics.go
+64
-94
@@ -42,6 +42,60 @@ const (
42
ProfileMetricTypePercent ProfileMetricType = "percent"
43
)
44
45
+// MetricsConfig holds configs for a metric
46
+type MetricsConfig struct {
47
+ // MIB the MIB used for this metric
48
+ MIB string `yaml:"MIB,omitempty" json:"MIB,omitempty"`
49
+
50
+ // Symbol configs
51
+ Symbol SymbolConfig `yaml:"symbol,omitempty" json:"symbol,omitempty"`
52
+
53
+ // Table the table OID
54
+ Table SymbolConfig `yaml:"table,omitempty" json:"table,omitempty"`
55
+ // Table configs
56
+ Symbols []SymbolConfig `yaml:"symbols,omitempty" json:"symbols,omitempty"`
57
+
58
+ // `static_tags` is not exposed as json at the moment since we need to evaluate if we want to expose it via UI
59
+ StaticTags []string `yaml:"static_tags,omitempty" json:"-"`
60
+ MetricTags MetricTagConfigList `yaml:"metric_tags,omitempty" json:"metric_tags,omitempty"`
61
+
62
+ Options MetricsConfigOption `yaml:"options,omitempty" json:"options,omitempty"`
63
+
64
+ // DEPRECATED: Use .Symbol instead
65
+ OID string `yaml:"OID,omitempty" json:"OID,omitempty" jsonschema:"-"`
66
+ // DEPRECATED: Use .Symbol instead
67
+ Name string `yaml:"name,omitempty" json:"name,omitempty" jsonschema:"-"`
68
+ // DEPRECATED: use Symbol.MetricType instead.
69
+ MetricType ProfileMetricType `yaml:"metric_type,omitempty" json:"metric_type,omitempty" jsonschema:"-"`
70
+}
71
+
72
+// Clone duplicates this MetricsConfig
73
+func (m MetricsConfig) Clone() MetricsConfig {
74
+ return MetricsConfig{
75
+ MIB: m.MIB,
76
+ Table: m.Table.Clone(),
77
+ Symbol: m.Symbol.Clone(),
78
+ Symbols: cloneSlice(m.Symbols),
79
+ StaticTags: slices.Clone(m.StaticTags),
80
+ MetricTags: cloneSlice(m.MetricTags),
81
+ Options: m.Options,
82
+
83
+ OID: m.OID,
84
+ Name: m.Name,
85
+ MetricType: m.MetricType,
86
+ }
87
+}
88
+
89
+// IsColumn returns true if the metrics config define columns metrics
90
+func (m *MetricsConfig) IsColumn() bool {
91
+ return len(m.Symbols) > 0
92
+}
93
+
94
+// IsScalar returns true if the metrics config define scalar metrics
95
+func (m *MetricsConfig) IsScalar() bool {
96
+ return m.Symbol.OID != "" && m.Symbol.Name != ""
97
+}
98
+
99
// SymbolConfigCompat is used to deserialize string field or SymbolConfig.
100
// For OID/Name to Symbol harmonization:
101
// When users declare metric tag like:
@@ -51,7 +105,7 @@ const (
105
// symbol: aSymbol
106
//
107
// this will lead to OID stored as MetricTagConfig.OID and name stored as MetricTagConfig.Symbol.Name
54
-// When this happens, in ValidateEnrichMetricTags we harmonize by moving MetricTagConfig.OID to MetricTagConfig.Symbol.OID.
108
+// When this happens, in validateEnrichMetricTags we harmonize by moving MetricTagConfig.OID to MetricTagConfig.Symbol.OID.
109
type SymbolConfigCompat SymbolConfig
110
111
// Clone creates a duplicate of this SymbolConfigCompat
@@ -88,13 +142,6 @@ type SymbolConfig struct {
142
TransformCompiled *template.Template `yaml:"-" json:"-"`
143
}
144
91
-type ChartMeta struct {
92
- Description string `yaml:"description,omitempty" json:"description,omitempty"`
93
- Family string `yaml:"family,omitempty" json:"family,omitempty"`
94
- Unit string `yaml:"unit,omitempty" json:"unit,omitempty"`
95
- Type string `yaml:"type,omitempty" json:"type,omitempty"`
96
-}
97
-
145
// Clone creates a duplicate of this SymbolConfig
146
func (s SymbolConfig) Clone() SymbolConfig {
147
ss := s
@@ -102,6 +149,13 @@ func (s SymbolConfig) Clone() SymbolConfig {
149
return ss
150
}
151
152
+type ChartMeta struct {
153
+ Description string `yaml:"description,omitempty" json:"description,omitempty"`
154
+ Family string `yaml:"family,omitempty" json:"family,omitempty"`
155
+ Unit string `yaml:"unit,omitempty" json:"unit,omitempty"`
156
+ Type string `yaml:"type,omitempty" json:"type,omitempty"`
157
+}
158
+
159
// MetricTagConfig holds metric tag info
160
type MetricTagConfig struct {
161
Tag string `yaml:"tag" json:"tag"`
@@ -124,8 +178,8 @@ type MetricTagConfig struct {
178
179
IndexTransform []MetricIndexTransform `yaml:"index_transform,omitempty" json:"index_transform,omitempty"`
180
127
- MappingRef string `yaml:"mapping_ref,omitempty" json:"mapping_ref,omitempty"`
128
- Mapping ListMap[string] `yaml:"mapping,omitempty" json:"mapping,omitempty"`
181
+ MappingRef string `yaml:"mapping_ref,omitempty" json:"mapping_ref,omitempty"`
182
+ Mapping map[string]string `yaml:"mapping,omitempty" json:"mapping,omitempty"`
183
184
// Regex
185
// Match/Tags are not exposed as json (UI) since ExtractValue can be used instead
@@ -162,87 +216,3 @@ type MetricsConfigOption struct {
216
Placement uint `yaml:"placement,omitempty" json:"placement,omitempty"`
217
MetricSuffix string `yaml:"metric_suffix,omitempty" json:"metric_suffix,omitempty"`
218
}
165
-
166
-// MetricsConfig holds configs for a metric
167
-type MetricsConfig struct {
168
- // MIB the MIB used for this metric
169
- MIB string `yaml:"MIB,omitempty" json:"MIB,omitempty"`
170
-
171
- // Table the table OID
172
- Table SymbolConfig `yaml:"table,omitempty" json:"table,omitempty"`
173
-
174
- // Symbol configs
175
- Symbol SymbolConfig `yaml:"symbol,omitempty" json:"symbol,omitempty"`
176
-
177
- // DEPRECATED: Use .Symbol instead
178
- OID string `yaml:"OID,omitempty" json:"OID,omitempty" jsonschema:"-"`
179
- // DEPRECATED: Use .Symbol instead
180
- Name string `yaml:"name,omitempty" json:"name,omitempty" jsonschema:"-"`
181
-
182
- // Table configs
183
- Symbols []SymbolConfig `yaml:"symbols,omitempty" json:"symbols,omitempty"`
184
-
185
- // `static_tags` is not exposed as json at the moment since we need to evaluate if we want to expose it via UI
186
- StaticTags []string `yaml:"static_tags,omitempty" json:"-"`
187
- MetricTags MetricTagConfigList `yaml:"metric_tags,omitempty" json:"metric_tags,omitempty"`
188
-
189
- // DEPRECATED: use Symbol.MetricType instead.
190
- ForcedType ProfileMetricType `yaml:"forced_type,omitempty" json:"forced_type,omitempty" jsonschema:"-"`
191
- // DEPRECATED: use Symbol.MetricType instead.
192
- MetricType ProfileMetricType `yaml:"metric_type,omitempty" json:"metric_type,omitempty" jsonschema:"-"`
193
-
194
- Options MetricsConfigOption `yaml:"options,omitempty" json:"options,omitempty"`
195
-}
196
-
197
-// Clone duplicates this MetricsConfig
198
-func (m MetricsConfig) Clone() MetricsConfig {
199
- return MetricsConfig{
200
- MIB: m.MIB,
201
- Table: m.Table.Clone(),
202
- Symbol: m.Symbol.Clone(),
203
- OID: m.OID,
204
- Name: m.Name,
205
- Symbols: CloneSlice(m.Symbols),
206
- StaticTags: slices.Clone(m.StaticTags),
207
- MetricTags: CloneSlice(m.MetricTags),
208
- ForcedType: m.ForcedType,
209
- MetricType: m.MetricType,
210
- Options: m.Options,
211
- }
212
-}
213
-
214
-// GetSymbolTags returns symbol tags
215
-func (m *MetricsConfig) GetSymbolTags() []string {
216
- var symbolTags []string
217
- for _, metricTag := range m.MetricTags {
218
- symbolTags = append(symbolTags, metricTag.SymbolTag)
219
- }
220
- return symbolTags
221
-}
222
-
223
-// IsColumn returns true if the metrics config define columns metrics
224
-func (m *MetricsConfig) IsColumn() bool {
225
- return len(m.Symbols) > 0
226
-}
227
-
228
-// IsScalar returns true if the metrics config define scalar metrics
229
-func (m *MetricsConfig) IsScalar() bool {
230
- return m.Symbol.OID != "" && m.Symbol.Name != ""
231
-}
232
-
233
-// NormalizeMetrics converts legacy syntax to new syntax
234
-// 1/ converts old symbol syntax to new symbol syntax
235
-// metric.Name and metric.OID info are moved to metric.Symbol.Name and metric.Symbol.OID
236
-func NormalizeMetrics(metrics []MetricsConfig) {
237
- for i := range metrics {
238
- metric := &metrics[i]
239
-
240
- // converts old symbol syntax to new symbol syntax
241
- if metric.Symbol.Name == "" && metric.Symbol.OID == "" && metric.Name != "" && metric.OID != "" {
242
- metric.Symbol.Name = metric.Name
243
- metric.Symbol.OID = metric.OID
244
- metric.Name = ""
245
- metric.OID = ""
246
- }
247
- }
248
-}
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/metrics_test.go
-1
@@ -149,7 +149,6 @@ func TestCloneMetricsConfig(t *testing.T) {
149
IndexTransform: make([]MetricIndexTransform, 0),
150
},
151
},
152
- ForcedType: ProfileMetricTypeCounter,
152
MetricType: ProfileMetricTypeGauge,
153
Options: MetricsConfigOption{
154
Placement: 1,
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/profile_definition.go
+10
-58
@@ -7,62 +7,20 @@ package ddprofiledefinition
7
8
import "slices"
9
10
-// DeviceMeta holds device related static metadata
11
-// DEPRECATED in favour of profile metadata syntax
12
-type DeviceMeta struct {
13
- // deprecated in favour of new `ProfileDefinition.Metadata` syntax
14
- Vendor string `yaml:"vendor,omitempty" json:"vendor,omitempty"`
15
-}
16
-
17
-// ProfileDefinition is the root profile structure. The ProfileDefinition is currently used in:
18
-// 1/ SNMP Integration: the profiles are in yaml profiles. Yaml profiles include default datadog profiles and user custom profiles.
19
-// The serialisation of yaml profiles are defined by the yaml annotation and few custom unmarshaller (see yaml_utils.go).
20
-// 2/ Datadog backend: the profiles are in json format, they are used to store profiles created via UI.
21
-// The serialisation of json profiles are defined by the json annotation.
10
+// ProfileDefinition is the root profile structure.
11
type ProfileDefinition struct {
23
- Name string `yaml:"name,omitempty" json:"name,omitempty"`
24
- Description string `yaml:"description,omitempty" json:"description,omitempty"`
25
-
26
- // Keep legacy field for backward compatibility
27
- SysObjectIDs StringArray `yaml:"sysobjectid,omitempty" json:"sysobjectid,omitempty"`
28
- // New, preferred matching
29
- Selector SelectorSpec `yaml:"selector,omitempty" json:"selector,omitempty"`
30
-
12
+ Selector SelectorSpec `yaml:"selector,omitempty" json:"selector,omitempty"`
13
Extends []string `yaml:"extends,omitempty" json:"extends,omitempty"`
14
Metadata MetadataConfig `yaml:"metadata,omitempty" json:"metadata,omitempty"`
15
SysobjectIDMetadata []SysobjectIDMetadataEntryConfig `yaml:"sysobjectid_metadata,omitempty"`
16
+ Metrics []MetricsConfig `yaml:"metrics,omitempty" json:"metrics,omitempty"`
17
MetricTags []MetricTagConfig `yaml:"metric_tags,omitempty" json:"metric_tags,omitempty"`
18
StaticTags []string `yaml:"static_tags,omitempty" json:"static_tags,omitempty"`
36
- Metrics []MetricsConfig `yaml:"metrics,omitempty" json:"metrics,omitempty"`
19
20
VirtualMetrics []VirtualMetricConfig `yaml:"virtual_metrics,omitempty" json:"virtual_metrics,omitempty"`
21
40
- // DEPRECATED: Use metadata directly
41
- Device DeviceMeta `yaml:"device,omitempty" json:"device,omitempty" jsonschema:"device,omitempty"`
42
-
43
- // Version is the profile version.
44
- // It is currently used only with downloaded/RC profiles.
45
- Version uint64 `yaml:"version,omitempty" json:"version,omitempty"`
46
-}
47
-
48
-// DeviceProfileRcConfig represent the profile stored in remote config.
49
-type DeviceProfileRcConfig struct {
50
- Profile ProfileDefinition `json:"profile_definition"`
51
-}
52
-
53
-// NewProfileDefinition creates a new ProfileDefinition
54
-func NewProfileDefinition() *ProfileDefinition {
55
- p := &ProfileDefinition{}
56
- p.Metadata = make(MetadataConfig)
57
- return p
58
-}
59
-
60
-// SplitOIDs returns two slices (scalars, columns) of all scalar and column OIDs requested by this profile.
61
-func (p *ProfileDefinition) SplitOIDs(includeMetadata bool) ([]string, []string) {
62
- if includeMetadata {
63
- return splitOIDs(p.Metrics, p.MetricTags, p.Metadata)
64
- }
65
- return splitOIDs(p.Metrics, p.MetricTags, nil)
22
+ // DEPRECATED: Keep legacy field for backward compatibility
23
+ SysObjectIDs StringArray `yaml:"sysobjectid,omitempty" json:"sysobjectid,omitempty"`
24
}
25
26
// Clone duplicates this ProfileDefinition
@@ -71,20 +29,14 @@ func (p *ProfileDefinition) Clone() *ProfileDefinition {
29
return nil
30
}
31
return &ProfileDefinition{
74
- Name: p.Name,
75
- Description: p.Description,
32
SysObjectIDs: slices.Clone(p.SysObjectIDs),
33
Selector: p.Selector.Clone(),
34
Extends: slices.Clone(p.Extends),
79
- Metadata: CloneMap(p.Metadata),
80
- SysobjectIDMetadata: CloneSlice(p.SysobjectIDMetadata),
81
- MetricTags: CloneSlice(p.MetricTags),
35
+ Metadata: cloneMap(p.Metadata),
36
+ SysobjectIDMetadata: cloneSlice(p.SysobjectIDMetadata),
37
+ MetricTags: cloneSlice(p.MetricTags),
38
StaticTags: slices.Clone(p.StaticTags),
83
- Metrics: CloneSlice(p.Metrics),
84
- VirtualMetrics: CloneSlice(p.VirtualMetrics),
85
- Device: DeviceMeta{
86
- Vendor: p.Device.Vendor,
87
- },
88
- Version: p.Version,
39
+ Metrics: cloneSlice(p.Metrics),
40
+ VirtualMetrics: cloneSlice(p.VirtualMetrics),
41
}
42
}
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/selector.go
+5
-8
@@ -15,8 +15,8 @@ type (
15
}
16
17
SelectorIncludeExclude struct {
18
- Include StringArray `yaml:"include,omitempty" json:"include,omitempty"`
19
- Exclude StringArray `yaml:"exclude,omitempty" json:"exclude,omitempty"`
18
+ Include []string `yaml:"include,omitempty" json:"include,omitempty"`
19
+ Exclude []string `yaml:"exclude,omitempty" json:"exclude,omitempty"`
20
}
21
)
22
@@ -46,12 +46,9 @@ func (ie SelectorIncludeExclude) clone() SelectorIncludeExclude {
46
}
47
48
func (s SelectorSpec) HasExactOidMatch(deviceSysObjectID string) bool {
49
- for _, rule := range s {
50
- if slices.ContainsFunc(rule.SysObjectID.Include, func(s string) bool { return deviceSysObjectID == s }) {
51
- return true
52
- }
53
- }
54
- return false
49
+ return slices.ContainsFunc(s, func(rule SelectorRule) bool {
50
+ return slices.Contains(rule.SysObjectID.Include, deviceSysObjectID)
51
+ })
52
}
53
54
func (s SelectorSpec) Matches(deviceSysObjectID, deviceSysDescr string) (bool, string) {
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/splitoids.go
deleted
-63
@@ -1,63 +0,0 @@
1
-// Unless explicitly stated otherwise all files in this repository are licensed
2
-// under the Apache License Version 2.0.
3
-// This product includes software developed at Datadog (https://www.datadoghq.com/).
4
-// Copyright 2023-present Datadog, Inc.
5
-
6
-package ddprofiledefinition
7
-
8
-import "sort"
9
-
10
-// splitOIDs returns all scalar and column (i.e. table) OIDs from metrics, tags, and metadata
11
-func splitOIDs(metrics []MetricsConfig, globalTags []MetricTagConfig, metadata MetadataConfig) ([]string, []string) {
12
- scalars := make(map[string]bool)
13
- columns := make(map[string]bool)
14
- // Singular metric values are scalars; metrics with .Symbols are tables,
15
- // and their symbols and tags are both expected to be columns.
16
- for _, metric := range metrics {
17
- scalars[metric.Symbol.OID] = true
18
- for _, symbolConfig := range metric.Symbols {
19
- columns[symbolConfig.OID] = true
20
- }
21
- for _, metricTag := range metric.MetricTags {
22
- columns[metricTag.Symbol.OID] = true
23
- }
24
- }
25
- // Global tags are scalar by definition
26
- for _, tag := range globalTags {
27
- scalars[tag.Symbol.OID] = true
28
- }
29
- // Metadata fields are all columns except when IsMetadataResourceWithScalarOids is true
30
- for resource, metadataConfig := range metadata {
31
- target := columns
32
- if IsMetadataResourceWithScalarOids(resource) {
33
- target = scalars
34
- }
35
- for _, field := range metadataConfig.Fields {
36
- target[field.Symbol.OID] = true
37
- for _, symbol := range field.Symbols {
38
- target[symbol.OID] = true
39
- }
40
- }
41
- for _, tagConfig := range metadataConfig.IDTags {
42
- target[tagConfig.Symbol.OID] = true
43
- }
44
- }
45
- scalarValues := make([]string, 0, len(scalars))
46
- for key := range scalars {
47
- if key == "" {
48
- continue
49
- }
50
- scalarValues = append(scalarValues, key)
51
- }
52
- columnValues := make([]string, 0, len(columns))
53
- for key := range columns {
54
- if key == "" {
55
- continue
56
- }
57
- columnValues = append(columnValues, key)
58
- }
59
- // Sort them for deterministic testing
60
- sort.Strings(scalarValues)
61
- sort.Strings(columnValues)
62
- return scalarValues, columnValues
63
-}
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/splitoids_test.go
deleted
-228
@@ -1,228 +0,0 @@
1
-// Unless explicitly stated otherwise all files in this repository are licensed
2
-// under the Apache License Version 2.0.
3
-// This product includes software developed at Datadog (https://www.datadoghq.com/).
4
-// Copyright 2023-present Datadog, Inc.
5
-
6
-package ddprofiledefinition
7
-
8
-import (
9
- "testing"
10
-
11
- "github.com/stretchr/testify/assert"
12
-)
13
-
14
-func TestSplitOIDs(t *testing.T) {
15
- type testCase struct {
16
- name string
17
- metrics []MetricsConfig
18
- tags []MetricTagConfig
19
- metadata MetadataConfig
20
- expectedScalars []string
21
- expectedColumns []string
22
- }
23
- testCases := []testCase{
24
- {
25
- name: "scalar metric",
26
- metrics: []MetricsConfig{{
27
- Symbol: SymbolConfig{
28
- OID: "1.2.3.4",
29
- },
30
- }},
31
- expectedScalars: []string{"1.2.3.4"},
32
- }, {
33
- name: "tabular metric",
34
- metrics: []MetricsConfig{{
35
- Symbols: []SymbolConfig{{OID: "1.2.3.4"}},
36
- MetricTags: []MetricTagConfig{
37
- {Symbol: SymbolConfigCompat{
38
- OID: "2.3.4.5",
39
- }},
40
- },
41
- }},
42
- expectedColumns: []string{"1.2.3.4", "2.3.4.5"},
43
- }, {
44
- name: "tags",
45
- tags: []MetricTagConfig{
46
- {Symbol: SymbolConfigCompat{
47
- OID: "2.3.4.5",
48
- },
49
- },
50
- },
51
- expectedScalars: []string{"2.3.4.5"},
52
- }, {
53
- name: "metadata",
54
- metadata: map[string]MetadataResourceConfig{
55
- "device": {
56
- Fields: map[string]MetadataField{
57
- "vendor": {Value: "static"},
58
- "name": {Symbol: SymbolConfig{
59
- OID: "1.1",
60
- }},
61
- "os_name": {Symbols: []SymbolConfig{
62
- {
63
- OID: "1.2",
64
- }, {
65
- OID: "1.3",
66
- },
67
- }},
68
- },
69
- IDTags: []MetricTagConfig{
70
- {Symbol: SymbolConfigCompat{
71
- OID: "1.4",
72
- }},
73
- },
74
- },
75
- "not_device": {
76
- Fields: map[string]MetadataField{
77
- "vendor": {Value: "static"},
78
- "name": {Symbol: SymbolConfig{
79
- OID: "2.1",
80
- }},
81
- "os_name": {Symbols: []SymbolConfig{
82
- {
83
- OID: "2.2",
84
- }, {
85
- OID: "2.3",
86
- },
87
- }},
88
- },
89
- IDTags: []MetricTagConfig{
90
- {Symbol: SymbolConfigCompat{
91
- OID: "2.4",
92
- }},
93
- },
94
- },
95
- },
96
- expectedScalars: []string{"1.1", "1.2", "1.3", "1.4"},
97
- expectedColumns: []string{"2.1", "2.2", "2.3", "2.4"},
98
- }, {
99
- name: "duplicates",
100
- metrics: []MetricsConfig{
101
- {
102
- Symbol: SymbolConfig{OID: "1.1"},
103
- }, {
104
- Symbols: []SymbolConfig{
105
- {OID: "1.1"},
106
- },
107
- MetricTags: []MetricTagConfig{
108
- {Symbol: SymbolConfigCompat{OID: "1.1"}},
109
- },
110
- }},
111
- metadata: map[string]MetadataResourceConfig{
112
- "device": {
113
- Fields: map[string]MetadataField{
114
- "name": {Symbol: SymbolConfig{
115
- OID: "1.1",
116
- }},
117
- },
118
- },
119
- },
120
- expectedScalars: []string{"1.1"},
121
- expectedColumns: []string{"1.1"},
122
- }, {
123
- name: "sorting",
124
- metrics: []MetricsConfig{
125
- {Symbol: SymbolConfig{OID: "1.2"}},
126
- {Symbol: SymbolConfig{OID: "1.1"}},
127
- {
128
- Symbols: []SymbolConfig{
129
- {OID: "2.4"},
130
- {OID: "2.3"},
131
- },
132
- MetricTags: []MetricTagConfig{
133
- {Symbol: SymbolConfigCompat{OID: "2.2"}},
134
- {Symbol: SymbolConfigCompat{OID: "2.1"}},
135
- },
136
- }},
137
- expectedScalars: []string{"1.1", "1.2"},
138
- expectedColumns: []string{"2.1", "2.2", "2.3", "2.4"},
139
- },
140
- }
141
- for _, tc := range testCases {
142
- t.Run(tc.name, func(t *testing.T) {
143
- scalars, columns := splitOIDs(tc.metrics, tc.tags, tc.metadata)
144
- expectedScalars := tc.expectedScalars
145
- if expectedScalars == nil {
146
- expectedScalars = []string{}
147
- }
148
- assert.Equal(t, expectedScalars, scalars)
149
- expectedColumns := tc.expectedColumns
150
- if expectedColumns == nil {
151
- expectedColumns = []string{}
152
- }
153
- assert.Equal(t, expectedColumns, columns)
154
- })
155
- }
156
-}
157
-
158
-func TestProfileSplitOIDs(t *testing.T) {
159
- p := ProfileDefinition{
160
- Metrics: []MetricsConfig{
161
- {Symbol: SymbolConfig{OID: "1.2"}},
162
- {Symbol: SymbolConfig{OID: "1.1"}},
163
- {
164
- Symbols: []SymbolConfig{
165
- {OID: "2.4"},
166
- {OID: "2.3"},
167
- },
168
- MetricTags: []MetricTagConfig{
169
- {Symbol: SymbolConfigCompat{OID: "2.2"}},
170
- {Symbol: SymbolConfigCompat{OID: "2.1"}},
171
- },
172
- },
173
- },
174
- MetricTags: []MetricTagConfig{
175
- {Symbol: SymbolConfigCompat{OID: "1.4"}},
176
- {Symbol: SymbolConfigCompat{OID: "1.3"}},
177
- },
178
- Metadata: map[string]MetadataResourceConfig{
179
- "device": {
180
- Fields: map[string]MetadataField{
181
- "vendor": {Value: "static"},
182
- "name": {Symbol: SymbolConfig{
183
- OID: "3.4",
184
- }},
185
- "os_name": {Symbols: []SymbolConfig{
186
- {
187
- OID: "3.3",
188
- }, {
189
- OID: "3.2",
190
- },
191
- }},
192
- },
193
- IDTags: []MetricTagConfig{
194
- {Symbol: SymbolConfigCompat{
195
- OID: "3.1",
196
- }},
197
- },
198
- },
199
- "not_device": {
200
- Fields: map[string]MetadataField{
201
- "vendor": {Value: "static"},
202
- "name": {Symbol: SymbolConfig{
203
- OID: "4.4",
204
- }},
205
- "os_name": {Symbols: []SymbolConfig{
206
- {
207
- OID: "4.3",
208
- }, {
209
- OID: "4.2",
210
- },
211
- }},
212
- },
213
- IDTags: []MetricTagConfig{
214
- {Symbol: SymbolConfigCompat{
215
- OID: "4.1",
216
- }},
217
- },
218
- },
219
- },
220
- }
221
- scalars, columns := p.SplitOIDs(true)
222
- assert.Equal(t, []string{"1.1", "1.2", "1.3", "1.4", "3.1", "3.2", "3.3", "3.4"}, scalars)
223
- assert.Equal(t, []string{"2.1", "2.2", "2.3", "2.4", "4.1", "4.2", "4.3", "4.4"}, columns)
224
-
225
- scalars, columns = p.SplitOIDs(false)
226
- assert.Equal(t, []string{"1.1", "1.2", "1.3", "1.4"}, scalars)
227
- assert.Equal(t, []string{"2.1", "2.2", "2.3", "2.4"}, columns)
228
-}
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/validation.go
+134
-133
@@ -51,117 +51,110 @@ const (
51
52
// ValidateEnrichProfile validates a profile and normalizes it.
53
func ValidateEnrichProfile(p *ProfileDefinition) error {
54
- NormalizeMetrics(p.Metrics)
54
+ normalizeMetrics(p.Metrics)
55
56
- var errs []error
57
-
58
- if err := validateEnrichLegacySelector(p); err != nil {
59
- errs = append(errs, err)
60
- }
61
- for _, err := range ValidateEnrichMetadata(p.Metadata) {
62
- errs = append(errs, errors.New(err))
63
- }
64
- for _, err := range ValidateEnrichSysobjectIDMetadata(p.SysobjectIDMetadata) {
65
- errs = append(errs, errors.New(err))
66
- }
67
- for _, err := range ValidateEnrichMetrics(p.Metrics) {
68
- errs = append(errs, errors.New(err))
69
- }
70
- for _, err := range ValidateEnrichMetricTags(p.MetricTags) {
71
- errs = append(errs, errors.New(err))
56
+ errs := []error{
57
+ validateEnrichLegacySelector(p),
58
+ validateEnrichMetadata(p.Metadata),
59
+ validateEnrichSysobjectIDMetadata(p.SysobjectIDMetadata),
60
+ validateEnrichMetrics(p.Metrics),
61
+ validateEnrichMetricTags(p.MetricTags),
62
}
63
64
return errors.Join(errs...)
65
}
66
77
-// ValidateEnrichMetricTags validates and normalizes metric tags
78
-func ValidateEnrichMetricTags(metricTags []MetricTagConfig) []string {
79
- var errs []string
80
- for i := range metricTags {
81
- errs = append(errs, validateEnrichMetricTag(&metricTags[i])...)
67
+// normalizeMetrics converts legacy syntax to new syntax
68
+// 1/ converts old symbol syntax to new symbol syntax
69
+// metric.Name and metric.OID info are moved to metric.Symbol.Name and metric.Symbol.OID
70
+func normalizeMetrics(metrics []MetricsConfig) {
71
+ for i := range metrics {
72
+ metric := &metrics[i]
73
+
74
+ // converts old symbol syntax to new symbol syntax
75
+ if metric.Symbol.Name == "" && metric.Symbol.OID == "" && metric.Name != "" && metric.OID != "" {
76
+ metric.Symbol.Name = metric.Name
77
+ metric.Symbol.OID = metric.OID
78
+ metric.Name = ""
79
+ metric.OID = ""
80
+ }
81
}
83
- return errs
82
}
83
86
-// ValidateEnrichMetrics will validate MetricsConfig and enrich it.
87
-// Example of enrichment:
88
-// - storage of compiled regex pattern
89
-func ValidateEnrichMetrics(metrics []MetricsConfig) []string {
90
- var errs []string
91
- for i := range metrics {
92
- metricConfig := &metrics[i]
93
- if !metricConfig.IsScalar() && !metricConfig.IsColumn() {
94
- errs = append(errs, fmt.Sprintf("either a table symbol or a scalar symbol must be provided: %#v", metricConfig))
95
- }
96
- if metricConfig.IsScalar() && metricConfig.IsColumn() {
97
- errs = append(errs, fmt.Sprintf("table symbol and scalar symbol cannot be both provided: %#v", metricConfig))
98
- }
99
- if metricConfig.IsScalar() {
100
- errs = append(errs, validateEnrichSymbol(&metricConfig.Symbol, ScalarSymbol)...)
84
+func validateEnrichLegacySelector(p *ProfileDefinition) error {
85
+ var errs []error
86
+
87
+ // If the new selector is absent but legacy sysobjectid exists, migrate it.
88
+ if len(p.Selector) == 0 && len(p.SysObjectIDs) > 0 {
89
+ p.Selector = SelectorSpec{
90
+ {
91
+ SysObjectID: SelectorIncludeExclude{
92
+ Include: slices.Clone(p.SysObjectIDs), // legacy -> include
93
+ },
94
+ },
95
}
102
- if metricConfig.IsColumn() {
103
- for j := range metricConfig.Symbols {
104
- errs = append(errs, validateEnrichSymbol(&metricConfig.Symbols[j], ColumnSymbol)...)
105
- }
106
- if len(metricConfig.MetricTags) == 0 {
107
- errs = append(errs, fmt.Sprintf("column symbols doesn't have a 'metric_tags' section (%+v), all its metrics will use the same tags; "+
108
- "if the table has multiple rows, only one row will be submitted; "+
109
- "please add at least one discriminating metric tag (such as a row index) "+
110
- "to ensure metrics of all rows are submitted", metricConfig.Symbols))
111
- }
112
- for i := range metricConfig.MetricTags {
113
- metricTag := &metricConfig.MetricTags[i]
114
- errs = append(errs, validateEnrichMetricTag(metricTag)...)
96
+ }
97
+
98
+ // Normalize and validate every rule
99
+ for i := range p.Selector {
100
+ r := &p.Selector[i]
101
+
102
+ // Validate regex syntax for sysObjectID includes/excludes
103
+ for j, pat := range r.SysObjectID.Include {
104
+ if _, err := regexp.Compile(pat); err != nil {
105
+ errs = append(errs, fmt.Errorf("selector[%d].sysObjectID.include[%d]: invalid regex %q: %v", i, j, pat, err))
106
}
107
}
117
- // Setting forced_type value to metric_type value for backward compatibility
118
- if metricConfig.MetricType == "" && metricConfig.ForcedType != "" {
119
- metricConfig.MetricType = metricConfig.ForcedType
108
+ for j, pat := range r.SysObjectID.Exclude {
109
+ if _, err := regexp.Compile(pat); err != nil {
110
+ errs = append(errs, fmt.Errorf("selector[%d].sysObjectID.exclude[%d]: invalid regex %q: %v", i, j, pat, err))
111
+ }
112
}
121
- metricConfig.ForcedType = ""
113
}
123
- return errs
114
+
115
+ return errors.Join(errs...)
116
}
117
126
-// ValidateEnrichMetadata will validate MetadataConfig and enrich it.
127
-func ValidateEnrichMetadata(metadata MetadataConfig) []string {
128
- var errs []string
118
+func validateEnrichMetadata(metadata MetadataConfig) error {
119
+ var errs []error
120
+
121
for resName := range metadata {
122
_, isValidRes := validMetadataResources[resName]
123
if !isValidRes {
132
- errs = append(errs, fmt.Sprintf("invalid resource: %s", resName))
124
+ errs = append(errs, fmt.Errorf("invalid resource: %s", resName))
125
} else {
126
res := metadata[resName]
127
for fieldName := range res.Fields {
128
_, isValidField := validMetadataResources[resName][fieldName]
129
if !isValidField {
138
- errs = append(errs, fmt.Sprintf("invalid resource (%s) field: %s", resName, fieldName))
130
+ errs = append(errs, fmt.Errorf("invalid resource (%s) field: %s", resName, fieldName))
131
continue
132
}
133
field := res.Fields[fieldName]
134
for i := range field.Symbols {
143
- errs = append(errs, validateEnrichSymbol(&field.Symbols[i], MetadataSymbol)...)
135
+ errs = append(errs, validateEnrichSymbol(&field.Symbols[i], MetadataSymbol))
136
}
137
if field.Symbol.OID != "" {
146
- errs = append(errs, validateEnrichSymbol(&field.Symbol, MetadataSymbol)...)
138
+ errs = append(errs, validateEnrichSymbol(&field.Symbol, MetadataSymbol))
139
}
140
res.Fields[fieldName] = field
141
}
142
metadata[resName] = res
143
}
144
if resName == "device" && len(metadata[resName].IDTags) > 0 {
153
- errs = append(errs, "device resource does not support custom id_tags")
145
+ errs = append(errs, errors.New("device resource does not support custom id_tags"))
146
}
147
for i := range metadata[resName].IDTags {
148
metricTag := &metadata[resName].IDTags[i]
157
- errs = append(errs, validateEnrichMetricTag(metricTag)...)
149
+ errs = append(errs, validateEnrichMetricTag(metricTag))
150
}
151
}
160
- return errs
152
+
153
+ return errors.Join(errs...)
154
}
155
163
-func ValidateEnrichSysobjectIDMetadata(entries []SysobjectIDMetadataEntryConfig) []string {
164
- var errs []string
156
+func validateEnrichSysobjectIDMetadata(entries []SysobjectIDMetadataEntryConfig) error {
157
+ var errs []error
158
159
// Track seen sysobjectids to detect duplicates
160
seenOIDs := make(map[string]int) // OID -> first occurrence index
@@ -169,13 +162,13 @@ func ValidateEnrichSysobjectIDMetadata(entries []SysobjectIDMetadataEntryConfig)
162
for i, entry := range entries {
163
// Validate sysobjectid is not empty
164
if entry.SysobjectID == "" {
172
- errs = append(errs, fmt.Sprintf("sysobjectid_metadata[%d]: missing sysobjectid", i))
165
+ errs = append(errs, fmt.Errorf("sysobjectid_metadata[%d]: missing sysobjectid", i))
166
continue
167
}
168
169
// Check for duplicate sysobjectids
170
if firstIdx, exists := seenOIDs[entry.SysobjectID]; exists {
178
- errs = append(errs, fmt.Sprintf("sysobjectid_metadata[%d]: duplicate sysobjectid %s (first occurrence at index %d)",
171
+ errs = append(errs, fmt.Errorf("sysobjectid_metadata[%d]: duplicate sysobjectid %s (first occurrence at index %d)",
172
i, entry.SysobjectID, firstIdx))
173
} else {
174
seenOIDs[entry.SysobjectID] = i
@@ -185,27 +178,25 @@ func ValidateEnrichSysobjectIDMetadata(entries []SysobjectIDMetadataEntryConfig)
178
for fieldName, field := range entry.Metadata {
179
// Validate the field must have either value or symbol(s)
180
if field.Value == "" && field.Symbol.OID == "" && len(field.Symbols) == 0 {
188
- errs = append(errs, fmt.Sprintf("sysobjectid_metadata[%d].%s: must have either value or symbol(s)", i, fieldName))
181
+ errs = append(errs, fmt.Errorf("sysobjectid_metadata[%d].%s: must have either value or symbol(s)", i, fieldName))
182
}
183
184
// Can't have both value and symbols
185
if field.Value != "" && (field.Symbol.OID != "" || len(field.Symbols) > 0) {
193
- errs = append(errs, fmt.Sprintf("sysobjectid_metadata[%d].%s: cannot have both value and symbol(s)", i, fieldName))
186
+ errs = append(errs, fmt.Errorf("sysobjectid_metadata[%d].%s: cannot have both value and symbol(s)", i, fieldName))
187
}
188
189
// Validate symbols if present
190
for j := range field.Symbols {
198
- symbolErrors := validateEnrichSymbol(&field.Symbols[j], MetadataSymbol)
199
- for _, err := range symbolErrors {
200
- errs = append(errs, fmt.Sprintf("sysobjectid_metadata[%d].%s.symbols[%d]: %s", i, fieldName, j, err))
191
+ if err := validateEnrichSymbol(&field.Symbols[j], MetadataSymbol); err != nil {
192
+ errs = append(errs, fmt.Errorf("sysobjectid_metadata[%d].%s.symbols[%d]: %s", i, fieldName, j, err))
193
}
194
}
195
196
// Validate single symbol if present
197
if field.Symbol.OID != "" {
206
- symbolErrors := validateEnrichSymbol(&field.Symbol, MetadataSymbol)
207
- for _, err := range symbolErrors {
208
- errs = append(errs, fmt.Sprintf("sysobjectid_metadata[%d].%s.symbol: %s", i, fieldName, err))
198
+ if err := validateEnrichSymbol(&field.Symbol, MetadataSymbol); err != nil {
199
+ errs = append(errs, fmt.Errorf("sysobjectid_metadata[%d].%s.symbol: %s", i, fieldName, err))
200
}
201
}
202
@@ -213,25 +204,68 @@ func ValidateEnrichSysobjectIDMetadata(entries []SysobjectIDMetadataEntryConfig)
204
}
205
}
206
216
- return errs
207
+ return errors.Join(errs...)
208
}
209
219
-func validateEnrichSymbol(symbol *SymbolConfig, symbolContext SymbolContext) []string {
220
- var errs []string
210
+func validateEnrichMetrics(metrics []MetricsConfig) error {
211
+ var errs []error
212
+
213
+ for i := range metrics {
214
+ metricConfig := &metrics[i]
215
+ if !metricConfig.IsScalar() && !metricConfig.IsColumn() {
216
+ errs = append(errs, fmt.Errorf("either a table symbol or a scalar symbol must be provided: %#v", metricConfig))
217
+ }
218
+ if metricConfig.IsScalar() && metricConfig.IsColumn() {
219
+ errs = append(errs, fmt.Errorf("table symbol and scalar symbol cannot be both provided: %#v", metricConfig))
220
+ }
221
+ if metricConfig.IsScalar() {
222
+ errs = append(errs, validateEnrichSymbol(&metricConfig.Symbol, ScalarSymbol))
223
+ }
224
+ if metricConfig.IsColumn() {
225
+ for j := range metricConfig.Symbols {
226
+ errs = append(errs, validateEnrichSymbol(&metricConfig.Symbols[j], ColumnSymbol))
227
+ }
228
+ if len(metricConfig.MetricTags) == 0 {
229
+ errs = append(errs, fmt.Errorf("column symbols doesn't have a 'metric_tags' section (%+v), all its metrics will use the same tags; "+
230
+ "if the table has multiple rows, only one row will be submitted; "+
231
+ "please add at least one discriminating metric tag (such as a row index) "+
232
+ "to ensure metrics of all rows are submitted", metricConfig.Symbols))
233
+ }
234
+ for i := range metricConfig.MetricTags {
235
+ metricTag := &metricConfig.MetricTags[i]
236
+ errs = append(errs, validateEnrichMetricTag(metricTag))
237
+ }
238
+ }
239
+ }
240
+
241
+ return errors.Join(errs...)
242
+}
243
+
244
+func validateEnrichMetricTags(metricTags []MetricTagConfig) error {
245
+ var errs []error
246
+ for i := range metricTags {
247
+ errs = append(errs, validateEnrichMetricTag(&metricTags[i]))
248
+ }
249
+ return errors.Join(errs...)
250
+}
251
+
252
+func validateEnrichSymbol(symbol *SymbolConfig, symbolContext SymbolContext) error {
253
+ var errs []error
254
+
255
if symbol.Name == "" {
222
- errs = append(errs, fmt.Sprintf("symbol name missing: name=`%s` oid=`%s`", symbol.Name, symbol.OID))
256
+ errs = append(errs, fmt.Errorf("symbol name missing: name=`%s` oid=`%s`", symbol.Name, symbol.OID))
257
}
258
if symbol.OID == "" {
259
if symbolContext == ColumnSymbol && !symbol.ConstantValueOne {
226
- errs = append(errs, fmt.Sprintf("symbol oid or send_as_one missing: name=`%s` oid=`%s`", symbol.Name, symbol.OID))
260
+ errs = append(errs, fmt.Errorf("symbol oid or send_as_one missing: name=`%s` oid=`%s`", symbol.Name, symbol.OID))
261
} else if symbolContext != ColumnSymbol {
228
- errs = append(errs, fmt.Sprintf("symbol oid missing: name=`%s` oid=`%s`", symbol.Name, symbol.OID))
262
+ errs = append(errs, fmt.Errorf("symbol oid missing: name=`%s` oid=`%s`", symbol.Name, symbol.OID))
263
}
264
}
265
if symbol.ExtractValue != "" {
266
pattern, err := regexp.Compile(symbol.ExtractValue)
267
if err != nil {
234
- errs = append(errs, fmt.Sprintf("cannot compile `extract_value` (%s): %s", symbol.ExtractValue, err.Error()))
268
+ errs = append(errs, fmt.Errorf("cannot compile `extract_value` (%s): %s", symbol.ExtractValue, err.Error()))
269
} else {
270
symbol.ExtractValueCompiled = pattern
271
}
@@ -239,24 +273,26 @@ func validateEnrichSymbol(symbol *SymbolConfig, symbolContext SymbolContext) []s
273
if symbol.MatchPattern != "" {
274
pattern, err := regexp.Compile(symbol.MatchPattern)
275
if err != nil {
242
- errs = append(errs, fmt.Sprintf("cannot compile `extract_value` (%s): %s", symbol.ExtractValue, err.Error()))
276
+ errs = append(errs, fmt.Errorf("cannot compile `match_pattern` (%s): %s", symbol.MatchPattern, err.Error()))
277
} else {
278
symbol.MatchPatternCompiled = pattern
279
}
280
}
281
if symbolContext != ColumnSymbol && symbol.ConstantValueOne {
248
- errs = append(errs, "`constant_value_one` cannot be used outside of tables")
282
+ errs = append(errs, errors.New("`constant_value_one` cannot be used outside of tables"))
283
}
284
if (symbolContext != ColumnSymbol && symbolContext != ScalarSymbol) && symbol.MetricType != "" {
251
- errs = append(errs, "`metric_type` cannot be used outside scalar/table metric symbols and metrics root")
285
+ errs = append(errs, errors.New("`metric_type` cannot be used outside scalar/table metric symbols and metrics root"))
286
}
253
- return errs
287
+
288
+ return errors.Join(errs...)
289
}
290
256
-func validateEnrichMetricTag(metricTag *MetricTagConfig) []string {
257
- var errs []string
291
+func validateEnrichMetricTag(metricTag *MetricTagConfig) error {
292
+ var errs []error
293
+
294
if (metricTag.Column.OID != "" || metricTag.Column.Name != "") && (metricTag.Symbol.OID != "" || metricTag.Symbol.Name != "") {
259
- errs = append(errs, fmt.Sprintf("metric tag symbol and column cannot be both declared: symbol=%v, column=%v", metricTag.Symbol, metricTag.Column))
295
+ errs = append(errs, fmt.Errorf("metric tag symbol and column cannot be both declared: symbol=%v, column=%v", metricTag.Symbol, metricTag.Column))
296
}
297
298
// Move deprecated metricTag.Column to metricTag.Symbol
@@ -273,7 +309,7 @@ func validateEnrichMetricTag(metricTag *MetricTagConfig) []string {
309
// this will lead to OID stored as MetricTagConfig.OID and name stored as MetricTagConfig.Symbol.Name
310
// When this happens, we harmonize by moving MetricTagConfig.OID to MetricTagConfig.Symbol.OID.
311
if metricTag.OID != "" && metricTag.Symbol.OID != "" {
276
- errs = append(errs, fmt.Sprintf("metric tag OID and symbol.OID cannot be both declared: OID=%s, symbol.OID=%s", metricTag.OID, metricTag.Symbol.OID))
312
+ errs = append(errs, fmt.Errorf("metric tag OID and symbol.OID cannot be both declared: OID=%s, symbol.OID=%s", metricTag.OID, metricTag.Symbol.OID))
313
}
314
if metricTag.OID != "" && metricTag.Symbol.OID == "" {
315
metricTag.Symbol.OID = metricTag.OID
@@ -281,61 +317,26 @@ func validateEnrichMetricTag(metricTag *MetricTagConfig) []string {
317
}
318
if metricTag.Symbol.OID != "" || metricTag.Symbol.Name != "" {
319
symbol := SymbolConfig(metricTag.Symbol)
284
- errs = append(errs, validateEnrichSymbol(&symbol, MetricTagSymbol)...)
320
+ errs = append(errs, validateEnrichSymbol(&symbol, MetricTagSymbol))
321
metricTag.Symbol = SymbolConfigCompat(symbol)
322
}
323
if metricTag.Match != "" {
324
pattern, err := regexp.Compile(metricTag.Match)
325
if err != nil {
290
- errs = append(errs, fmt.Sprintf("cannot compile `match` (`%s`): %s", metricTag.Match, err.Error()))
326
+ errs = append(errs, fmt.Errorf("cannot compile `match` (`%s`): %s", metricTag.Match, err.Error()))
327
} else {
328
metricTag.Pattern = pattern
329
}
330
if len(metricTag.Tags) == 0 {
295
- errs = append(errs, fmt.Sprintf("`tags` mapping must be provided if `match` (`%s`) is defined", metricTag.Match))
331
+ errs = append(errs, fmt.Errorf("`tags` mapping must be provided if `match` (`%s`) is defined", metricTag.Match))
332
}
333
}
334
if len(metricTag.Mapping) > 0 && metricTag.Tag == "" {
299
- errs = append(errs, fmt.Sprintf("``tag` must be provided if `mapping` (`%s`) is defined", metricTag.Mapping))
335
+ errs = append(errs, fmt.Errorf("``tag` must be provided if `mapping` (`%s`) is defined", metricTag.Mapping))
336
}
337
for _, transform := range metricTag.IndexTransform {
338
if transform.Start > transform.End {
303
- errs = append(errs, fmt.Sprintf("transform rule end should be greater than start. Invalid rule: %#v", transform))
304
- }
305
- }
306
- return errs
307
-}
308
-
309
-// validateEnrichLegacySelector migrates legacy sysobjectid into selector include/exclude
310
-// and validates that all OID patterns compile as regex.
311
-func validateEnrichLegacySelector(p *ProfileDefinition) error {
312
- var errs []error
313
-
314
- // If the new selector is absent but legacy sysobjectid exists, migrate it.
315
- if len(p.Selector) == 0 && len(p.SysObjectIDs) > 0 {
316
- p.Selector = SelectorSpec{
317
- {
318
- SysObjectID: SelectorIncludeExclude{
319
- Include: slices.Clone(p.SysObjectIDs), // legacy -> include
320
- },
321
- },
322
- }
323
- }
324
-
325
- // Normalize and validate every rule
326
- for i := range p.Selector {
327
- r := &p.Selector[i]
328
-
329
- // Validate regex syntax for sysObjectID includes/excludes
330
- for j, pat := range r.SysObjectID.Include {
331
- if _, err := regexp.Compile(pat); err != nil {
332
- errs = append(errs, fmt.Errorf("selector[%d].sysObjectID.include[%d]: invalid regex %q: %v", i, j, pat, err))
333
- }
334
- }
335
- for j, pat := range r.SysObjectID.Exclude {
336
- if _, err := regexp.Compile(pat); err != nil {
337
- errs = append(errs, fmt.Errorf("selector[%d].sysObjectID.exclude[%d]: invalid regex %q: %v", i, j, pat, err))
338
- }
339
+ errs = append(errs, fmt.Errorf("transform rule end should be greater than start. Invalid rule: %#v", transform))
340
}
341
}
342
src/go/plugin/go.d/collector/snmp/ddsnmp/ddprofiledefinition/validation_test.go
+110
-245
@@ -6,34 +6,29 @@
6
package ddprofiledefinition
7
8
import (
9
- "fmt"
9
"regexp"
10
"testing"
11
12
"github.com/stretchr/testify/assert"
13
)
14
16
-func Test_ValidateEnrichMetrics(t *testing.T) {
17
- tests := []struct {
18
- name string
19
- metrics []MetricsConfig
20
- expectedErrors []string
21
- expectedMetrics []MetricsConfig
15
+func Test_validateEnrichMetrics(t *testing.T) {
16
+ tests := map[string]struct {
17
+ metrics []MetricsConfig
18
+ wantError bool
19
+ wantMetrics []MetricsConfig
20
}{
23
- {
24
- name: "either table symbol or scalar symbol must be provided",
21
+ "either table symbol or scalar symbol must be provided": {
22
+ wantError: true,
23
metrics: []MetricsConfig{
24
{},
25
},
28
- expectedErrors: []string{
29
- "either a table symbol or a scalar symbol must be provided",
30
- },
31
- expectedMetrics: []MetricsConfig{
26
+ wantMetrics: []MetricsConfig{
27
{},
28
},
29
},
35
- {
36
- name: "table column symbols and scalar symbol cannot be both provided",
30
+ "table column symbols and scalar symbol cannot be both provided": {
31
+ wantError: true,
32
metrics: []MetricsConfig{
33
{
34
Symbol: SymbolConfig{
@@ -51,12 +46,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
46
},
47
},
48
},
54
- expectedErrors: []string{
55
- "table symbol and scalar symbol cannot be both provided",
56
- },
49
},
58
- {
59
- name: "multiple errors",
50
+ "multiple errors": {
51
+ wantError: true,
52
metrics: []MetricsConfig{
53
{},
54
{
@@ -75,13 +67,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
67
},
68
},
69
},
78
- expectedErrors: []string{
79
- "either a table symbol or a scalar symbol must be provided",
80
- "table symbol and scalar symbol cannot be both provided",
81
- },
70
},
83
- {
84
- name: "missing symbol name",
71
+ "missing symbol name": {
72
+ wantError: true,
73
metrics: []MetricsConfig{
74
{
75
Symbol: SymbolConfig{
@@ -89,12 +77,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
77
},
78
},
79
},
92
- expectedErrors: []string{
93
- "either a table symbol or a scalar symbol must be provided",
94
- },
80
},
96
- {
97
- name: "table column symbol name missing",
81
+ "table column symbol name missing": {
82
+ wantError: true,
83
metrics: []MetricsConfig{
84
{
85
Symbols: []SymbolConfig{
@@ -110,13 +95,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
95
},
96
},
97
},
113
- expectedErrors: []string{
114
- "symbol name missing: name=`` oid=`1.2`",
115
- "symbol oid or send_as_one missing: name=`abc` oid=``",
116
- },
98
},
118
- {
119
- name: "table external metric column tag symbol error",
99
+ "table external metric column tag symbol error": {
100
+ wantError: true,
101
metrics: []MetricsConfig{
102
{
103
Symbols: []SymbolConfig{
@@ -139,13 +120,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
120
},
121
},
122
},
142
- expectedErrors: []string{
143
- "symbol name missing: name=`` oid=`1.2.3`",
144
- "symbol oid missing: name=`abc` oid=``",
145
- },
123
},
147
- {
148
- name: "missing MetricTags",
124
+ "missing MetricTags": {
125
+ wantError: true,
126
metrics: []MetricsConfig{
127
{
128
Symbols: []SymbolConfig{
@@ -157,12 +134,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
134
MetricTags: MetricTagConfigList{},
135
},
136
},
160
- expectedErrors: []string{
161
- "column symbols doesn't have a 'metric_tags' section",
162
- },
137
},
164
- {
165
- name: "table external metric column tag MIB error",
138
+ "table external metric column tag MIB error": {
139
+ wantError: true,
140
metrics: []MetricsConfig{
141
{
142
Symbols: []SymbolConfig{
@@ -185,13 +159,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
159
},
160
},
161
},
188
- expectedErrors: []string{
189
- "symbol name missing: name=`` oid=`1.2.3`",
190
- "symbol oid missing: name=`abc` oid=``",
191
- },
162
},
193
- {
194
- name: "missing match tags",
163
+ "missing match tags": {
164
+ wantError: true,
165
metrics: []MetricsConfig{
166
{
167
Symbols: []SymbolConfig{
@@ -211,12 +181,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
181
},
182
},
183
},
214
- expectedErrors: []string{
215
- "`tags` mapping must be provided if `match` (`([a-z])`) is defined",
216
- },
184
},
218
- {
219
- name: "match cannot compile regex",
185
+ "match cannot compile regex": {
186
+ wantError: true,
187
metrics: []MetricsConfig{
188
{
189
Symbols: []SymbolConfig{
@@ -239,12 +206,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
206
},
207
},
208
},
242
- expectedErrors: []string{
243
- "cannot compile `match` (`([a-z)`)",
244
- },
209
},
246
- {
247
- name: "match cannot compile regex",
210
+ "match cannot compile regex 2": {
211
+ wantError: true,
212
metrics: []MetricsConfig{
213
{
214
Symbols: []SymbolConfig{
@@ -270,12 +234,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
234
},
235
},
236
},
273
- expectedErrors: []string{
274
- "transform rule end should be greater than start. Invalid rule",
275
- },
237
},
277
- {
278
- name: "compiling extract_value",
238
+ "compiling extract_value": {
239
+ wantError: false,
240
metrics: []MetricsConfig{
241
{
242
Symbol: SymbolConfig{
@@ -304,7 +265,7 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
265
},
266
},
267
},
307
- expectedMetrics: []MetricsConfig{
268
+ wantMetrics: []MetricsConfig{
269
{
270
Symbol: SymbolConfig{
271
OID: "1.2.3",
@@ -335,10 +296,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
296
},
297
},
298
},
338
- expectedErrors: []string{},
299
},
340
- {
341
- name: "error compiling extract_value",
300
+ "error compiling extract_value": {
301
+ wantError: true,
302
metrics: []MetricsConfig{
303
{
304
Symbol: SymbolConfig{
@@ -348,12 +308,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
308
},
309
},
310
},
351
- expectedErrors: []string{
352
- "cannot compile `extract_value`",
353
- },
311
},
355
- {
356
- name: "constant_value_one usage in column symbol",
312
+ "constant_value_one usage in column symbol": {
313
+ wantError: false,
314
metrics: []MetricsConfig{
315
{
316
Symbols: []SymbolConfig{
@@ -373,10 +330,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
330
},
331
},
332
},
376
- expectedErrors: []string{},
333
},
378
- {
379
- name: "constant_value_one usage in scalar symbol",
334
+ "constant_value_one usage in scalar symbol": {
335
+ wantError: true,
336
metrics: []MetricsConfig{
337
{
338
Symbol: SymbolConfig{
@@ -385,12 +341,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
341
},
342
},
343
},
388
- expectedErrors: []string{
389
- "either a table symbol or a scalar symbol must be provided",
390
- },
344
},
392
- {
393
- name: "constant_value_one usage in scalar symbol with OID",
345
+ "constant_value_one usage in scalar symbol with OID": {
346
+ wantError: true,
347
metrics: []MetricsConfig{
348
{
349
Symbol: SymbolConfig{
@@ -400,12 +353,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
353
},
354
},
355
},
403
- expectedErrors: []string{
404
- "`constant_value_one` cannot be used outside of tables",
405
- },
356
},
407
- {
408
- name: "constant_value_one usage in metric tags",
357
+ "constant_value_one usage in metric tags": {
358
+ wantError: true,
359
metrics: []MetricsConfig{
360
{
361
Symbols: []SymbolConfig{
@@ -425,13 +375,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
375
},
376
},
377
},
428
- expectedErrors: []string{
429
- "symbol oid missing",
430
- "`constant_value_one` cannot be used outside of tables",
431
- },
378
},
433
- {
434
- name: "metric_type usage in column symbol",
379
+ "metric_type usage in column symbol": {
380
+ wantError: false,
381
metrics: []MetricsConfig{
382
{
383
Symbols: []SymbolConfig{
@@ -452,10 +398,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
398
},
399
},
400
},
455
- expectedErrors: []string{},
401
},
457
- {
458
- name: "metric_type usage in scalar symbol",
402
+ "metric_type usage in scalar symbol": {
403
+ wantError: false,
404
metrics: []MetricsConfig{
405
{
406
Symbol: SymbolConfig{
@@ -465,10 +410,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
410
},
411
},
412
},
468
- expectedErrors: []string{},
413
},
470
- {
471
- name: "ERROR metric_type usage in metric_tags",
414
+ "ERROR metric_type usage in metric_tags": {
415
+ wantError: true,
416
metrics: []MetricsConfig{
417
{
418
Symbols: []SymbolConfig{
@@ -489,55 +433,9 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
433
},
434
},
435
},
492
- expectedErrors: []string{
493
- "`metric_type` cannot be used outside scalar/table metric symbols and metrics root",
494
- },
436
},
496
- {
497
- name: "metric root forced_type converted to metric_type",
498
- metrics: []MetricsConfig{
499
- {
500
- ForcedType: ProfileMetricTypeCounter,
501
- Symbols: []SymbolConfig{
502
- {
503
- Name: "abc",
504
- OID: "1.2.3",
505
- },
506
- },
507
- MetricTags: MetricTagConfigList{
508
- MetricTagConfig{
509
- Symbol: SymbolConfigCompat{
510
- Name: "abc",
511
- OID: "1.2.3",
512
- },
513
- Tag: "hello",
514
- },
515
- },
516
- },
517
- },
518
- expectedMetrics: []MetricsConfig{
519
- {
520
- MetricType: ProfileMetricTypeCounter,
521
- Symbols: []SymbolConfig{
522
- {
523
- Name: "abc",
524
- OID: "1.2.3",
525
- },
526
- },
527
- MetricTags: MetricTagConfigList{
528
- MetricTagConfig{
529
- Symbol: SymbolConfigCompat{
530
- Name: "abc",
531
- OID: "1.2.3",
532
- },
533
- Tag: "hello",
534
- },
535
- },
536
- },
537
- },
538
- },
539
- {
540
- name: "mapping used without tag",
437
+ "mapping used without tag": {
438
+ wantError: true,
439
metrics: []MetricsConfig{
440
{
441
Symbols: []SymbolConfig{
@@ -560,32 +458,30 @@ func Test_ValidateEnrichMetrics(t *testing.T) {
458
},
459
},
460
},
563
- expectedErrors: []string{"`tag` must be provided if `mapping` (`map[1:abc 2:def]`) is defined"},
461
},
462
}
566
- for _, tt := range tests {
567
- t.Run(tt.name, func(t *testing.T) {
568
- errors := ValidateEnrichMetrics(tt.metrics)
569
- assert.Equal(t, len(tt.expectedErrors), len(errors), fmt.Sprintf("ERRORS: %v", errors))
570
- for i := range errors {
571
- assert.Contains(t, errors[i], tt.expectedErrors[i])
463
+ for name, tc := range tests {
464
+ t.Run(name, func(t *testing.T) {
465
+ if tc.wantError {
466
+ assert.Error(t, validateEnrichMetrics(tc.metrics))
467
+ } else {
468
+ assert.NoError(t, validateEnrichMetrics(tc.metrics))
469
}
573
- if tt.expectedMetrics != nil {
574
- assert.Equal(t, tt.expectedMetrics, tt.metrics)
470
+ if tc.wantMetrics != nil {
471
+ assert.Equal(t, tc.wantMetrics, tc.metrics)
472
}
473
})
474
}
475
}
476
580
-func Test_ValidateEnrichMetricTags(t *testing.T) {
581
- tests := []struct {
582
- name string
583
- metrics []MetricTagConfig
584
- expectedErrors []string
585
- expectedMetrics []MetricTagConfig
477
+func Test_validateEnrichMetricTags(t *testing.T) {
478
+ tests := map[string]struct {
479
+ metrics []MetricTagConfig
480
+ wantError bool
481
+ wantMetrics []MetricTagConfig
482
}{
587
- {
588
- name: "Move OID to Symbol",
483
+ "Move OID to Symbol": {
484
+ wantError: false,
485
metrics: []MetricTagConfig{
486
{
487
OID: "1.2.3.4",
@@ -594,7 +490,7 @@ func Test_ValidateEnrichMetricTags(t *testing.T) {
490
},
491
},
492
},
597
- expectedMetrics: []MetricTagConfig{
493
+ wantMetrics: []MetricTagConfig{
494
{
495
Symbol: SymbolConfigCompat{
496
OID: "1.2.3.4",
@@ -603,8 +499,8 @@ func Test_ValidateEnrichMetricTags(t *testing.T) {
499
},
500
},
501
},
606
- {
607
- name: "Metric tag OID and symbol.OID cannot be both declared",
502
+ "Metric tag OID and symbol.OID cannot be both declared": {
503
+ wantError: true,
504
metrics: []MetricTagConfig{
505
{
506
OID: "1.2.3.4",
@@ -614,12 +510,9 @@ func Test_ValidateEnrichMetricTags(t *testing.T) {
510
},
511
},
512
},
617
- expectedErrors: []string{
618
- "metric tag OID and symbol.OID cannot be both declared",
619
- },
513
},
621
- {
622
- name: "metric tag symbol and column cannot be both declared",
514
+ "metric tag symbol and column cannot be both declared 2": {
515
+ wantError: true,
516
metrics: []MetricTagConfig{
517
{
518
Symbol: SymbolConfigCompat{
@@ -632,12 +525,9 @@ func Test_ValidateEnrichMetricTags(t *testing.T) {
525
},
526
},
527
},
635
- expectedErrors: []string{
636
- "metric tag symbol and column cannot be both declared",
637
- },
528
},
639
- {
640
- name: "Missing OID",
529
+ "Missing OID": {
530
+ wantError: true,
531
metrics: []MetricTagConfig{
532
{
533
Symbol: SymbolConfigCompat{
@@ -645,34 +535,30 @@ func Test_ValidateEnrichMetricTags(t *testing.T) {
535
},
536
},
537
},
648
- expectedErrors: []string{
649
- "symbol oid missing",
650
- },
538
},
539
}
653
- for _, tt := range tests {
654
- t.Run(tt.name, func(t *testing.T) {
655
- errors := ValidateEnrichMetricTags(tt.metrics)
656
- assert.Equal(t, len(tt.expectedErrors), len(errors), fmt.Sprintf("ERRORS: %v", errors))
657
- for i := range errors {
658
- assert.Contains(t, errors[i], tt.expectedErrors[i])
540
+ for name, tc := range tests {
541
+ t.Run(name, func(t *testing.T) {
542
+ if tc.wantError {
543
+ assert.Error(t, validateEnrichMetricTags(tc.metrics))
544
+ } else {
545
+ assert.NoError(t, validateEnrichMetricTags(tc.metrics))
546
}
660
- if tt.expectedMetrics != nil {
661
- assert.Equal(t, tt.expectedMetrics, tt.metrics)
547
+ if tc.wantMetrics != nil {
548
+ assert.Equal(t, tc.wantMetrics, tc.metrics)
549
}
550
})
551
}
552
}
553
554
func Test_validateEnrichMetadata(t *testing.T) {
668
- tests := []struct {
669
- name string
670
- metadata MetadataConfig
671
- expectedErrors []string
672
- expectedMetadata MetadataConfig
555
+ tests := map[string]struct {
556
+ metadata MetadataConfig
557
+ wantError bool
558
+ wantMetadata MetadataConfig
559
}{
674
- {
675
- name: "both field symbol and value can be provided",
560
+ "both field symbol and value can be provided": {
561
+ wantError: false,
562
metadata: MetadataConfig{
563
"device": MetadataResourceConfig{
564
Fields: map[string]MetadataField{
@@ -686,7 +572,7 @@ func Test_validateEnrichMetadata(t *testing.T) {
572
},
573
},
574
},
689
- expectedMetadata: MetadataConfig{
575
+ wantMetadata: MetadataConfig{
576
"device": MetadataResourceConfig{
577
Fields: map[string]MetadataField{
578
"name": {
@@ -700,8 +586,8 @@ func Test_validateEnrichMetadata(t *testing.T) {
586
},
587
},
588
},
703
- {
704
- name: "invalid regex pattern for symbol",
589
+ "invalid regex pattern for symbol": {
590
+ wantError: true,
591
metadata: MetadataConfig{
592
"device": MetadataResourceConfig{
593
Fields: map[string]MetadataField{
@@ -715,12 +601,9 @@ func Test_validateEnrichMetadata(t *testing.T) {
601
},
602
},
603
},
718
- expectedErrors: []string{
719
- "cannot compile `extract_value`",
720
- },
604
},
722
- {
723
- name: "invalid regex pattern for multiple symbols",
605
+ "invalid regex pattern for multiple symbols": {
606
+ wantError: true,
607
metadata: MetadataConfig{
608
"device": MetadataResourceConfig{
609
Fields: map[string]MetadataField{
@@ -736,12 +619,9 @@ func Test_validateEnrichMetadata(t *testing.T) {
619
},
620
},
621
},
739
- expectedErrors: []string{
740
- "cannot compile `extract_value`",
741
- },
622
},
743
- {
744
- name: "field regex pattern is compiled",
623
+ "field regex pattern is compiled": {
624
+ wantError: false,
625
metadata: MetadataConfig{
626
"device": MetadataResourceConfig{
627
Fields: map[string]MetadataField{
@@ -755,8 +635,7 @@ func Test_validateEnrichMetadata(t *testing.T) {
635
},
636
},
637
},
758
- expectedErrors: []string{},
759
- expectedMetadata: MetadataConfig{
638
+ wantMetadata: MetadataConfig{
639
"device": MetadataResourceConfig{
640
Fields: map[string]MetadataField{
641
"name": {
@@ -771,8 +650,8 @@ func Test_validateEnrichMetadata(t *testing.T) {
650
},
651
},
652
},
774
- {
775
- name: "invalid resource",
653
+ "invalid resource": {
654
+ wantError: true,
655
metadata: MetadataConfig{
656
"invalid-res": MetadataResourceConfig{
657
Fields: map[string]MetadataField{
@@ -782,12 +661,9 @@ func Test_validateEnrichMetadata(t *testing.T) {
661
},
662
},
663
},
785
- expectedErrors: []string{
786
- "invalid resource: invalid-res",
787
- },
664
},
789
- {
790
- name: "invalid field",
665
+ "invalid field": {
666
+ wantError: true,
667
metadata: MetadataConfig{
668
"device": MetadataResourceConfig{
669
Fields: map[string]MetadataField{
@@ -797,12 +673,9 @@ func Test_validateEnrichMetadata(t *testing.T) {
673
},
674
},
675
},
800
- expectedErrors: []string{
801
- "invalid resource (device) field: invalid-field",
802
- },
676
},
804
- {
805
- name: "invalid idtags",
677
+ "invalid idtags": {
678
+ wantError: true,
679
metadata: MetadataConfig{
680
"interface": MetadataResourceConfig{
681
Fields: map[string]MetadataField{
@@ -824,13 +697,9 @@ func Test_validateEnrichMetadata(t *testing.T) {
697
},
698
},
699
},
827
- expectedErrors: []string{
828
- "invalid resource (interface) field: invalid-field",
829
- "cannot compile `match` (`([a-z)`)",
830
- },
700
},
832
- {
833
- name: "device resource does not support id_tags",
701
+ "device resource does not support id_tags": {
702
+ wantError: true,
703
metadata: MetadataConfig{
704
"device": MetadataResourceConfig{
705
Fields: map[string]MetadataField{
@@ -849,23 +718,19 @@ func Test_validateEnrichMetadata(t *testing.T) {
718
},
719
},
720
},
852
- expectedErrors: []string{
853
- "device resource does not support custom id_tags",
854
- },
721
},
722
}
857
- for _, tt := range tests {
858
- t.Run(tt.name, func(t *testing.T) {
859
- errors := ValidateEnrichMetadata(tt.metadata)
860
- assert.Equal(t, len(tt.expectedErrors), len(errors), fmt.Sprintf("ERRORS: %v", errors))
861
- for i := range errors {
862
- assert.Contains(t, errors[i], tt.expectedErrors[i])
723
+
724
+ for name, tc := range tests {
725
+ t.Run(name, func(t *testing.T) {
726
+ if tc.wantError {
727
+ assert.Error(t, validateEnrichMetadata(tc.metadata))
728
+ } else {
729
+ assert.NoError(t, validateEnrichMetadata(tc.metadata))
730
}
864
- if tt.expectedMetadata != nil {
865
- assert.Equal(t, tt.expectedMetadata, tt.metadata)
731
+ if tc.wantMetadata != nil {
732
+ assert.Equal(t, tc.wantMetadata, tc.metadata)
733
}
734
})
735
}
736
}
870
-
871
-// TODO: Add test for ValidateEnrichMetricTags
src/go/plugin/go.d/collector/snmp/ddsnmp/ddsnmpcollector/collector_device_meta_test.go
+39
-39
@@ -40,7 +40,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
40
Definition: &ddprofiledefinition.ProfileDefinition{
41
Metadata: ddprofiledefinition.MetadataConfig{
42
"device": ddprofiledefinition.MetadataResourceConfig{
43
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
43
+ Fields: map[string]ddprofiledefinition.MetadataField{
44
"vendor": {Value: "dell"},
45
"type": {Value: "router"},
46
"model": {Value: "PowerEdge R740"},
@@ -62,7 +62,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
62
Definition: &ddprofiledefinition.ProfileDefinition{
63
Metadata: ddprofiledefinition.MetadataConfig{
64
"device": ddprofiledefinition.MetadataResourceConfig{
65
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
65
+ Fields: map[string]ddprofiledefinition.MetadataField{
66
"vendor": {Value: "dell"},
67
"serial_number": {
68
Symbol: ddprofiledefinition.SymbolConfig{
@@ -107,7 +107,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
107
Definition: &ddprofiledefinition.ProfileDefinition{
108
Metadata: ddprofiledefinition.MetadataConfig{
109
"device": ddprofiledefinition.MetadataResourceConfig{
110
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
110
+ Fields: map[string]ddprofiledefinition.MetadataField{
111
"serial_number": {
112
Symbols: []ddprofiledefinition.SymbolConfig{
113
{OID: "1.3.6.1.4.1.674.10892.5.1.3.2.0", Name: "chassisSerialNumber"},
@@ -143,7 +143,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
143
Definition: &ddprofiledefinition.ProfileDefinition{
144
Metadata: ddprofiledefinition.MetadataConfig{
145
"device": ddprofiledefinition.MetadataResourceConfig{
146
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
146
+ Fields: map[string]ddprofiledefinition.MetadataField{
147
"version": {
148
Symbol: ddprofiledefinition.SymbolConfig{
149
OID: "1.3.6.1.2.1.1.1.0",
@@ -177,7 +177,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
177
Definition: &ddprofiledefinition.ProfileDefinition{
178
Metadata: ddprofiledefinition.MetadataConfig{
179
"device": ddprofiledefinition.MetadataResourceConfig{
180
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
180
+ Fields: map[string]ddprofiledefinition.MetadataField{
181
"temperature": {
182
Symbol: ddprofiledefinition.SymbolConfig{
183
OID: "1.3.6.1.4.1.674.10892.5.4.200.10.1.2.1.3.1",
@@ -210,7 +210,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
210
Definition: &ddprofiledefinition.ProfileDefinition{
211
Metadata: ddprofiledefinition.MetadataConfig{
212
"device": ddprofiledefinition.MetadataResourceConfig{
213
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
213
+ Fields: map[string]ddprofiledefinition.MetadataField{
214
"status": {
215
Symbol: ddprofiledefinition.SymbolConfig{
216
OID: "1.3.6.1.4.1.674.10892.5.2.1.0",
@@ -250,7 +250,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
250
Definition: &ddprofiledefinition.ProfileDefinition{
251
Metadata: ddprofiledefinition.MetadataConfig{
252
"device": ddprofiledefinition.MetadataResourceConfig{
253
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
253
+ Fields: map[string]ddprofiledefinition.MetadataField{
254
"mac_address": {
255
Symbol: ddprofiledefinition.SymbolConfig{
256
OID: "1.3.6.1.2.1.2.2.1.6.1",
@@ -283,12 +283,12 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
283
Definition: &ddprofiledefinition.ProfileDefinition{
284
Metadata: ddprofiledefinition.MetadataConfig{
285
"interface": ddprofiledefinition.MetadataResourceConfig{
286
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
286
+ Fields: map[string]ddprofiledefinition.MetadataField{
287
"name": {Value: "eth0"},
288
},
289
},
290
"device": ddprofiledefinition.MetadataResourceConfig{
291
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
291
+ Fields: map[string]ddprofiledefinition.MetadataField{
292
"vendor": {Value: "cisco"},
293
},
294
},
@@ -306,7 +306,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
306
Definition: &ddprofiledefinition.ProfileDefinition{
307
Metadata: ddprofiledefinition.MetadataConfig{
308
"device": ddprofiledefinition.MetadataResourceConfig{
309
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
309
+ Fields: map[string]ddprofiledefinition.MetadataField{
310
"serial_number": {
311
Symbol: ddprofiledefinition.SymbolConfig{
312
OID: "1.3.6.1.4.1.674.10892.5.1.3.2.0",
@@ -331,7 +331,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
331
Definition: &ddprofiledefinition.ProfileDefinition{
332
Metadata: ddprofiledefinition.MetadataConfig{
333
"device": ddprofiledefinition.MetadataResourceConfig{
334
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
334
+ Fields: map[string]ddprofiledefinition.MetadataField{
335
"vendor": {Value: "dell"},
336
"serial_number": {
337
Symbol: ddprofiledefinition.SymbolConfig{
@@ -375,7 +375,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
375
Definition: &ddprofiledefinition.ProfileDefinition{
376
Metadata: ddprofiledefinition.MetadataConfig{
377
"device": ddprofiledefinition.MetadataResourceConfig{
378
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
378
+ Fields: map[string]ddprofiledefinition.MetadataField{
379
"field1": {Symbol: ddprofiledefinition.SymbolConfig{OID: "1.3.6.1.2.1.1.1.0", Name: "oid1"}},
380
"field2": {Symbol: ddprofiledefinition.SymbolConfig{OID: "1.3.6.1.2.1.1.2.0", Name: "oid2"}},
381
"field3": {Symbol: ddprofiledefinition.SymbolConfig{OID: "1.3.6.1.2.1.1.3.0", Name: "oid3"}},
@@ -414,7 +414,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
414
Definition: &ddprofiledefinition.ProfileDefinition{
415
Metadata: ddprofiledefinition.MetadataConfig{
416
"device": {
417
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
417
+ Fields: map[string]ddprofiledefinition.MetadataField{
418
"vendor": {Value: "Cisco"},
419
"type": {Value: "Firewall"},
420
},
@@ -423,14 +423,14 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
423
SysobjectIDMetadata: []ddprofiledefinition.SysobjectIDMetadataEntryConfig{
424
{
425
SysobjectID: "1.3.6.1.4.1.9.1.669",
426
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
426
+ Metadata: map[string]ddprofiledefinition.MetadataField{
427
"model": {Value: "ASA5510"},
428
"series": {Value: "ASA5500"},
429
},
430
},
431
{
432
SysobjectID: "1.3.6.1.4.1.9.1.670",
433
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
433
+ Metadata: map[string]ddprofiledefinition.MetadataField{
434
"model": {Value: "ASA5520"},
435
},
436
},
@@ -452,7 +452,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
452
Definition: &ddprofiledefinition.ProfileDefinition{
453
Metadata: ddprofiledefinition.MetadataConfig{
454
"device": {
455
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
455
+ Fields: map[string]ddprofiledefinition.MetadataField{
456
"vendor": {Value: "Cisco"},
457
"platform": {Value: "Default Platform"},
458
},
@@ -461,14 +461,14 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
461
SysobjectIDMetadata: []ddprofiledefinition.SysobjectIDMetadataEntryConfig{
462
{
463
SysobjectID: "1.3.6.1.4.1.9.*",
464
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
464
+ Metadata: map[string]ddprofiledefinition.MetadataField{
465
"platform": {Value: "Enterprise"},
466
"support": {Value: "Premium"},
467
},
468
},
469
{
470
SysobjectID: "1.3.6.1.4.1.9.1.*",
471
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
471
+ Metadata: map[string]ddprofiledefinition.MetadataField{
472
"type": {Value: "Firewall"},
473
"series": {Value: "ASA"},
474
"support": {Value: "Standard"},
@@ -476,7 +476,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
476
},
477
{
478
SysobjectID: "1.3.6.1.4.1.9.1.669",
479
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
479
+ Metadata: map[string]ddprofiledefinition.MetadataField{
480
"model": {Value: "ASA5510"},
481
"series": {Value: "ASA5500"},
482
},
@@ -500,12 +500,12 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
500
profile: &ddsnmp.Profile{
501
Definition: &ddprofiledefinition.ProfileDefinition{
502
Metadata: ddprofiledefinition.MetadataConfig{
503
- "device": {Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{"vendor": {Value: "Cisco"}}},
503
+ "device": {Fields: map[string]ddprofiledefinition.MetadataField{"vendor": {Value: "Cisco"}}},
504
},
505
SysobjectIDMetadata: []ddprofiledefinition.SysobjectIDMetadataEntryConfig{
506
{
507
SysobjectID: "1.3.6.1.4.1.9.1.669",
508
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
508
+ Metadata: map[string]ddprofiledefinition.MetadataField{
509
"model": {Value: "ASA5510"},
510
"firmware": {Symbol: ddprofiledefinition.SymbolConfig{
511
OID: "1.3.6.1.4.1.9.9.109.1.1.1.1.3.1",
@@ -537,7 +537,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
537
Definition: &ddprofiledefinition.ProfileDefinition{
538
Metadata: ddprofiledefinition.MetadataConfig{
539
"device": {
540
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
540
+ Fields: map[string]ddprofiledefinition.MetadataField{
541
"vendor": {Value: "Cisco"},
542
"type": {Value: "Firewall"},
543
},
@@ -546,7 +546,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
546
SysobjectIDMetadata: []ddprofiledefinition.SysobjectIDMetadataEntryConfig{
547
{
548
SysobjectID: "1.3.6.1.4.1.9.1.669",
549
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{"model": {Value: "ASA5510"}},
549
+ Metadata: map[string]ddprofiledefinition.MetadataField{"model": {Value: "ASA5510"}},
550
},
551
},
552
},
@@ -563,16 +563,16 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
563
profile: &ddsnmp.Profile{
564
Definition: &ddprofiledefinition.ProfileDefinition{
565
Metadata: ddprofiledefinition.MetadataConfig{
566
- "device": {Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{"vendor": {Value: "Cisco"}}},
566
+ "device": {Fields: map[string]ddprofiledefinition.MetadataField{"vendor": {Value: "Cisco"}}},
567
},
568
SysobjectIDMetadata: []ddprofiledefinition.SysobjectIDMetadataEntryConfig{
569
{
570
SysobjectID: "1.3.6.1.4.1.9.1.[invalid",
571
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{"model": {Value: "ASA5510"}},
571
+ Metadata: map[string]ddprofiledefinition.MetadataField{"model": {Value: "ASA5510"}},
572
},
573
{
574
SysobjectID: "1.3.6.1.4.1.9.1.669",
575
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{"series": {Value: "ASA5500"}},
575
+ Metadata: map[string]ddprofiledefinition.MetadataField{"series": {Value: "ASA5500"}},
576
},
577
},
578
},
@@ -590,7 +590,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
590
Definition: &ddprofiledefinition.ProfileDefinition{
591
Metadata: ddprofiledefinition.MetadataConfig{
592
"device": {
593
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
593
+ Fields: map[string]ddprofiledefinition.MetadataField{
594
"vendor": {Value: "Generic"},
595
"type": {Value: "Unknown"},
596
"model": {Value: "Generic Model"},
@@ -600,7 +600,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
600
SysobjectIDMetadata: []ddprofiledefinition.SysobjectIDMetadataEntryConfig{
601
{
602
SysobjectID: "1.3.6.1.4.1.9.1.669",
603
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
603
+ Metadata: map[string]ddprofiledefinition.MetadataField{
604
"vendor": {Value: "Cisco Systems"},
605
"model": {Value: "ASA5510"},
606
},
@@ -621,12 +621,12 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
621
profile: &ddsnmp.Profile{
622
Definition: &ddprofiledefinition.ProfileDefinition{
623
Metadata: ddprofiledefinition.MetadataConfig{
624
- "device": {Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{"vendor": {Value: "Cisco"}}},
624
+ "device": {Fields: map[string]ddprofiledefinition.MetadataField{"vendor": {Value: "Cisco"}}},
625
},
626
SysobjectIDMetadata: []ddprofiledefinition.SysobjectIDMetadataEntryConfig{
627
{
628
SysobjectID: "1.3.6.1.4.1.9.1.669",
629
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
629
+ Metadata: map[string]ddprofiledefinition.MetadataField{
630
"model": {Value: "ASA5510"},
631
"firmware": {Symbol: ddprofiledefinition.SymbolConfig{
632
OID: "1.3.6.1.4.1.9.9.109.1.1.1.1.3.1",
@@ -653,7 +653,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
653
Definition: &ddprofiledefinition.ProfileDefinition{
654
Metadata: ddprofiledefinition.MetadataConfig{
655
"device": {
656
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
656
+ Fields: map[string]ddprofiledefinition.MetadataField{
657
"vendor": {Value: "Cisco"},
658
"os_name": {
659
Symbols: []ddprofiledefinition.SymbolConfig{
@@ -689,7 +689,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
689
Definition: &ddprofiledefinition.ProfileDefinition{
690
Metadata: ddprofiledefinition.MetadataConfig{
691
"device": {
692
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
692
+ Fields: map[string]ddprofiledefinition.MetadataField{
693
"vendor": {Value: "Juniper"},
694
"os_name": {
695
Symbols: []ddprofiledefinition.SymbolConfig{
@@ -722,7 +722,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
722
Definition: &ddprofiledefinition.ProfileDefinition{
723
Metadata: ddprofiledefinition.MetadataConfig{
724
"device": {
725
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
725
+ Fields: map[string]ddprofiledefinition.MetadataField{
726
"vendor": {Value: "Generic"},
727
"os_name": {
728
Symbol: ddprofiledefinition.SymbolConfig{
@@ -757,7 +757,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
757
Definition: &ddprofiledefinition.ProfileDefinition{
758
Metadata: ddprofiledefinition.MetadataConfig{
759
"device": {
760
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
760
+ Fields: map[string]ddprofiledefinition.MetadataField{
761
"vendor": {Value: "Cisco"},
762
"version": {Symbol: ddprofiledefinition.SymbolConfig{
763
OID: "1.3.6.1.2.1.1.1.0",
@@ -810,7 +810,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
810
},
811
Metadata: ddprofiledefinition.MetadataConfig{
812
"device": {
813
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
813
+ Fields: map[string]ddprofiledefinition.MetadataField{
814
"vendor": {Value: "Cisco"},
815
"type": {Value: "Firewall"},
816
"model": {Value: "Generic"},
@@ -840,7 +840,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
840
},
841
Metadata: ddprofiledefinition.MetadataConfig{
842
"device": {
843
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
843
+ Fields: map[string]ddprofiledefinition.MetadataField{
844
"platform": {Value: "Enterprise-Exact"},
845
"series": {Value: "ASA-Exact"},
846
},
@@ -849,7 +849,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
849
SysobjectIDMetadata: []ddprofiledefinition.SysobjectIDMetadataEntryConfig{
850
{
851
SysobjectID: "1.3.6.1.4.1.9.1.*", // wildcard match (not exact)
852
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
852
+ Metadata: map[string]ddprofiledefinition.MetadataField{
853
"platform": {Value: "Enterprise-Wildcard"},
854
"series": {Value: "ASA-Wildcard"},
855
"model": {Value: "ASA5510-Wildcard"},
@@ -874,7 +874,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
874
Definition: &ddprofiledefinition.ProfileDefinition{
875
Metadata: ddprofiledefinition.MetadataConfig{
876
"device": {
877
- Fields: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
877
+ Fields: map[string]ddprofiledefinition.MetadataField{
878
"platform": {Value: "Enterprise-Base"},
879
"series": {Value: "ASA-Base"},
880
},
@@ -883,7 +883,7 @@ func TestDeviceMetadataCollector_Collect(t *testing.T) {
883
SysobjectIDMetadata: []ddprofiledefinition.SysobjectIDMetadataEntryConfig{
884
{
885
SysobjectID: "1.3.6.1.4.1.9.1.*", // wildcard
886
- Metadata: ddprofiledefinition.ListMap[ddprofiledefinition.MetadataField]{
886
+ Metadata: map[string]ddprofiledefinition.MetadataField{
887
"platform": {Value: "Enterprise-Wildcard"},
888
"series": {Value: "ASA-Wildcard"},
889
"model": {Value: "ASA5510"},
src/go/plugin/go.d/collector/snmp/ddsnmp/profile.go
+1
-1
@@ -195,7 +195,7 @@ func (p *Profile) mergeMetadata(base *Profile) {
195
for resName, baseRes := range base.Definition.Metadata {
196
targetRes, exists := p.Definition.Metadata[resName]
197
if !exists {
198
- targetRes = ddprofiledefinition.NewMetadataResourceConfig()
198
+ targetRes = ddprofiledefinition.MetadataResourceConfig{}
199
}
200
201
targetRes.IDTags = append(targetRes.IDTags, baseRes.IDTags...)
src/go/plugin/go.d/config/go.d/snmp.profiles/default/_cisco-wlc.yaml
+5
-2
@@ -1,8 +1,11 @@
1
# Base profile for Cisco Wireless LAN Controllers
2
# This profile is only compatible with the core SNMP integration
3
4
-device:
5
- vendor: "cisco"
4
+metadata:
5
+ device:
6
+ fields:
7
+ vendor:
8
+ value: Cisco
9
10
metrics:
11
# Connected APs metrics
src/go/plugin/go.d/config/go.d/snmp.profiles/default/aruba-access-point.yaml
+2
-3
@@ -19,9 +19,6 @@ selector:
19
include:
20
- 1.3.6.1.4.1.14823.1.2.*
21
22
-device:
23
- vendor: "Aruba"
24
-
22
metadata:
23
device:
24
fields:
@@ -58,3 +55,5 @@ metadata:
55
# Example: `6.5.1.0` part of `Version 6.5.1.0-4.3.1.2`
56
type:
57
value: "Access Point"
58
+ vendor:
59
+ value: Aruba
src/go/plugin/go.d/config/go.d/snmp.profiles/default/cisco-legacy-wlc.yaml
-58
@@ -39,64 +39,6 @@ selector:
39
- 1.3.6.1.4.1.9.1.2171 # cisco8540Wlc
40
- 1.3.6.1.4.1.9.1.2427 # cisco3504WLC
41
42
-sysobjectid_metadata:
43
- - sysobjectid: 1.3.6.1.4.1.9.1.818
44
- metadata:
45
- model:
46
- value: NM-WLC-E
47
- - sysobjectid: 1.3.6.1.4.1.9.1.828
48
- metadata:
49
- model:
50
- value: AIR-WLC2106-K9
51
- - sysobjectid: 1.3.6.1.4.1.9.1.926
52
- metadata:
53
- model:
54
- value: 520-WLC
55
- - sysobjectid: 1.3.6.1.4.1.9.1.1069
56
- metadata:
57
- model:
58
- value: 5500-WLC
59
- - sysobjectid: 1.3.6.1.4.1.9.1.1279
60
- metadata:
61
- model:
62
- value: AIR-CT2504-K9
63
- - sysobjectid: 1.3.6.1.4.1.9.1.1295
64
- metadata:
65
- model:
66
- value: 7500-WLC
67
- - sysobjectid: 1.3.6.1.4.1.9.1.1615
68
- metadata:
69
- model:
70
- value: 8500-WLC
71
- - sysobjectid: 1.3.6.1.4.1.9.1.1631
72
- metadata:
73
- model:
74
- value: Virtual-WLC
75
- - sysobjectid: 1.3.6.1.4.1.9.1.1645
76
- metadata:
77
- model:
78
- value: 5760-WLC
79
- - sysobjectid: 1.3.6.1.4.1.9.1.1926
80
- metadata:
81
- model:
82
- value: WLC-CT5508-K9
83
- - sysobjectid: 1.3.6.1.4.1.9.1.1927
84
- metadata:
85
- model:
86
- value: WLC-CT2504-K9
87
- - sysobjectid: 1.3.6.1.4.1.9.1.2170
88
- metadata:
89
- model:
90
- value: 5520-WLC
91
- - sysobjectid: 1.3.6.1.4.1.9.1.2171
92
- metadata:
93
- model:
94
- value: 8540-WLC
95
- - sysobjectid: 1.3.6.1.4.1.9.1.2427
96
- metadata:
97
- model:
98
- value: 3504-WLC
99
-
42
metrics:
43
- MIB: AIRESPACE-SWITCHING-MIB
44
symbol:
src/go/plugin/go.d/config/go.d/snmp.profiles/default/fortinet-fortigate.yaml
-3
@@ -7,9 +7,6 @@ extends:
7
- _std-if-mib.yaml
8
- _fortinet-fortigate-vpn-tunnel.yaml
9
10
-device:
11
- vendor: "fortinet"
12
-
10
# All fortinet devices have sysObjectID starting with `1.3.6.1.4.1.12356.101.1` (fgModel)
11
# We only target Fortinet Fortigate devices (1.3.6.1.4.1.12356.101/fnFortiGateMib)
12
selector:
src/go/plugin/go.d/config/go.d/snmp.profiles/default/hp-ilo4.yaml
+2
-3
@@ -6,9 +6,6 @@
6
extends:
7
- hp-ilo.yaml
8
9
-device:
10
- vendor: "hp"
11
-
9
selector:
10
- sysobjectid:
11
include:
@@ -19,3 +16,5 @@ metadata:
16
fields:
17
model:
18
value: iLO4
19
+ vendor:
20
+ value: HP
src/go/plugin/go.d/config/go.d/snmp.profiles/metadata/cisco.yaml
+20
-13
@@ -2356,7 +2356,8 @@ sysobjectids:
2356
category: Firewall
2357
model: IPSSSM10VIRTUAL
2358
1.3.6.1.4.1.9.1.818:
2359
- model: NMWLCE
2359
+ category: Wireless LAN Controller
2360
+ model: NM-WLC-E
2361
1.3.6.1.4.1.9.1.819:
2362
category: Wireless
2363
model: Cisco3205Wireless
@@ -2386,7 +2387,7 @@ sysobjectids:
2387
model: uBR 7225Vxr
2388
1.3.6.1.4.1.9.1.828:
2389
category: Wireless LAN Controller
2389
- model: 2106 Wireless Controller
2390
+ model: AIR-WLC2106-K9
2391
1.3.6.1.4.1.9.1.829:
2392
category: Router
2393
model: ciscoMwr1951DC
@@ -2677,8 +2678,8 @@ sysobjectids:
2678
category: Router
2679
model: ASR 1006
2680
1.3.6.1.4.1.9.1.926:
2680
- category: Wireless
2681
- model: 520WirelessController
2681
+ category: Wireless LAN Controller
2682
+ model: 520-WLC
2683
1.3.6.1.4.1.9.1.927:
2684
category: Switch
2685
model: Catalyst 2960-48TC-S
@@ -3100,7 +3101,7 @@ sysobjectids:
3101
model: SMAXP
3102
1.3.6.1.4.1.9.1.1069:
3103
category: Wireless LAN Controller
3103
- model: 5508 Wireless Controller
3104
+ model: 5508-WLC
3105
1.3.6.1.4.1.9.1.1070:
3106
category: Router
3107
model: SR520T1
@@ -3711,7 +3712,7 @@ sysobjectids:
3712
model: Catalyst 2960C PD-8TT
3713
1.3.6.1.4.1.9.1.1279:
3714
category: Wireless LAN Controller
3714
- model: 2504 Wireless Controller
3715
+ model: AIR-CT2504-K9
3716
1.3.6.1.4.1.9.1.1280:
3717
model: ISMAXP
3718
1.3.6.1.4.1.9.1.1281:
@@ -3749,7 +3750,7 @@ sysobjectids:
3750
model: CDScde250
3751
1.3.6.1.4.1.9.1.1295:
3752
category: Wireless LAN Controller
3752
- model: Flex 7510
3753
+ model: Flex 7510-WLC
3754
1.3.6.1.4.1.9.1.1296:
3755
model: AnmVirtualApp
3756
1.3.6.1.4.1.9.1.1297:
@@ -4555,7 +4556,7 @@ sysobjectids:
4556
model: ASA1000V
4557
1.3.6.1.4.1.9.1.1615:
4558
category: Wireless LAN Controller
4558
- model: 8500 Wireless Controller
4559
+ model: 8500-WLC
4560
1.3.6.1.4.1.9.1.1616:
4561
category: Switch
4562
model: ME 3600X-24CX-M
@@ -4594,7 +4595,7 @@ sysobjectids:
4595
model: ciscoCSE340G32K9
4596
1.3.6.1.4.1.9.1.1631:
4597
category: Wireless LAN Controller
4597
- model: Virtual Wireless Controller
4598
+ model: Virtual-WLC
4599
1.3.6.1.4.1.9.1.1632:
4600
model: AIRAP802agn
4601
1.3.6.1.4.1.9.1.1633:
@@ -4633,7 +4634,7 @@ sysobjectids:
4634
category: Layer 3 Switch
4635
model: Catalyst 3850-24T
4636
1.3.6.1.4.1.9.1.1645:
4636
- category: Wireless
4637
+ category: Wireless LAN Controller
4638
model: AIR 5760 WLC
4639
1.3.6.1.4.1.9.1.1646:
4640
model: VSGateway
@@ -5200,6 +5201,12 @@ sysobjectids:
5201
1.3.6.1.4.1.9.1.1925:
5202
category: Layer 3 Switch
5203
model: Nexus 9396PX
5204
+ 1.3.6.1.4.1.9.1.1926:
5205
+ category: Wireless LAN Controller
5206
+ model: WLC-CT5508-K9
5207
+ 1.3.6.1.4.1.9.1.1927:
5208
+ category: Wireless LAN Controller
5209
+ model: WLC-CT2504-K9
5210
1.3.6.1.4.1.9.1.1930:
5211
model: "2514"
5212
1.3.6.1.4.1.9.1.1931:
@@ -5740,10 +5747,10 @@ sysobjectids:
5747
model: RAIE1783ZMS8T8E2TGN
5748
1.3.6.1.4.1.9.1.2170:
5749
category: Wireless LAN Controller
5743
- model: 5520 Wireless Controller
5750
+ model: 5520-WLC
5751
1.3.6.1.4.1.9.1.2171:
5752
category: Wireless LAN Controller
5746
- model: 8540 Wireless Controller
5753
+ model: 8540-WLC
5754
1.3.6.1.4.1.9.1.2172:
5755
category: Switch
5756
model: ROCKWELL STRATIX 1783-HMS8TG4CGR
@@ -6357,7 +6364,7 @@ sysobjectids:
6364
model: IR809GLTELAK9
6365
1.3.6.1.4.1.9.1.2427:
6366
category: Wireless LAN Controller
6360
- model: 3504 Wireless Controller
6367
+ model: 3504-WLC
6368
1.3.6.1.4.1.9.1.2428:
6369
category: Router
6370
model: NCS-55A1-36H-SE