@cryptotaxi247 / netdata-1 / commits / 0e2286260

chore(go.d/snmp): make enable_profiles configurable (needed for dev) (#20255)

Ilya Mashchenko committed May 8, 2025 at 12:57 UTC 0e228626084a08dd6766a86dce45e7535e976c03
6 files changed +14 -13
src/go/plugin/go.d/collector/snmp/collect.go
+1 -1
@@ -20,7 +20,7 @@ func (c *Collector) collect() (map[string]int64, error) {
20
21 mx := make(map[string]int64)
22
23 - if c.enableProfiles {
23 + if c.EnableProfiles {
24 sysObjectID, err := c.getSysObjectID(snmpsd.OidSysObject)
25 if err != nil {
26 return nil, err
src/go/plugin/go.d/collector/snmp/collector.go
-2
@@ -66,8 +66,6 @@ type Collector struct {
66 module.Base
67 Config `yaml:",inline" json:""`
68
69 - enableProfiles bool
70 -
69 vnode *vnodes.VirtualNode
70
71 charts *module.Charts
src/go/plugin/go.d/collector/snmp/collector_test.go
+9 -9
@@ -156,7 +156,7 @@ func TestCollector_Charts(t *testing.T) {
156 prepareSNMP: func(t *testing.T, m *snmpmock.MockHandler) *Collector {
157 collr := New()
158 collr.Config = prepareV2Config()
159 - if collr.enableProfiles {
159 + if collr.EnableProfiles {
160 setMockClientSysObjectidExpect(m)
161 }
162 setMockClientSysExpect(m)
@@ -208,7 +208,7 @@ func TestCollector_Check(t *testing.T) {
208 prepareSNMP: func(m *snmpmock.MockHandler) *Collector {
209 collr := New()
210 collr.Config = prepareV2Config()
211 - if collr.enableProfiles {
211 + if collr.EnableProfiles {
212 setMockClientSysObjectidExpect(m)
213 }
214 setMockClientIfMibExpect(m)
@@ -223,7 +223,7 @@ func TestCollector_Check(t *testing.T) {
223 collr.Config = prepareConfigWithUserCharts(prepareV2Config(), 0, 3)
224 collr.collectIfMib = false
225
226 - if collr.enableProfiles {
226 + if collr.EnableProfiles {
227 setMockClientSysObjectidExpect(m)
228 }
229
@@ -249,7 +249,7 @@ func TestCollector_Check(t *testing.T) {
249 collr := New()
250 collr.Config = prepareConfigWithUserCharts(prepareV2Config(), 0, 3)
251 collr.collectIfMib = false
252 - if collr.enableProfiles {
252 + if collr.EnableProfiles {
253 setMockClientSysObjectidExpect(m)
254 }
255 m.EXPECT().Get(gomock.Any()).Return(nil, errors.New("mock Get() error")).Times(1)
@@ -291,7 +291,7 @@ func TestCollector_Collect(t *testing.T) {
291 collr := New()
292 collr.Config = prepareV2Config()
293
294 - if collr.enableProfiles {
294 + if collr.EnableProfiles {
295 setMockClientSysObjectidExpect(m)
296 }
297 setMockClientIfMibExpect(m)
@@ -397,7 +397,7 @@ func TestCollector_Collect(t *testing.T) {
397 collr.Config = prepareConfigWithUserCharts(prepareV2Config(), 0, 3)
398 collr.collectIfMib = false
399
400 - if collr.enableProfiles {
400 + if collr.EnableProfiles {
401 setMockClientSysObjectidExpect(m)
402 }
403
@@ -435,7 +435,7 @@ func TestCollector_Collect(t *testing.T) {
435 collr.Config = prepareConfigWithUserCharts(prepareV2Config(), 0, 2)
436 collr.collectIfMib = false
437
438 - if collr.enableProfiles {
438 + if collr.EnableProfiles {
439 setMockClientSysObjectidExpect(m)
440 }
441
@@ -466,7 +466,7 @@ func TestCollector_Collect(t *testing.T) {
466 collr.Config = prepareConfigWithUserCharts(prepareV2Config(), 0, 2)
467 collr.collectIfMib = false
468
469 - if collr.enableProfiles {
469 + if collr.EnableProfiles {
470 setMockClientSysObjectidExpect(m)
471 }
472
@@ -505,7 +505,7 @@ func TestCollector_Collect(t *testing.T) {
505
506 mx := collr.Collect(context.Background())
507
508 - if collr.enableProfiles {
508 + if collr.EnableProfiles {
509 mx["TestMetric"] = 1
510 }
511
src/go/plugin/go.d/collector/snmp/config.go
+1
@@ -15,6 +15,7 @@ type (
15 Options Options `yaml:"options,omitempty" json:"options"`
16 ChartsInput []ChartConfig `yaml:"charts,omitempty" json:"charts"`
17 NetworkInterfaceFilter NetworkInterfaceFilter `yaml:"network_interface_filter,omitempty" json:"network_interface_filter"`
18 + EnableProfiles bool `yaml:"enable_profiles,omitempty" json:"enable_profiles"`
19 }
20 NetworkInterfaceFilter struct {
21 ByName string `yaml:"by_name,omitempty" json:"by_name"`
src/go/plugin/go.d/collector/snmp/testdata/config.json
+2 -1
@@ -52,5 +52,6 @@
52 }
53 ]
54 }
55 - ]
55 + ],
56 + "enable_profiles": true
57 }
src/go/plugin/go.d/collector/snmp/testdata/config.yaml
+1
@@ -1,6 +1,7 @@
1 update_every: 123
2 hostname: "ok"
3 create_vnode: yes
4 +enable_profiles: yes
5 vnode:
6 name: "ok"
7 guid: "ok"