@cryptotaxi247 / netdata-1 / commits / 328981529

chore(go.d/snmp): add disable_legacy_collection option (#20606)

Ilya Mashchenko committed Jun 30, 2025 at 16:17 UTC 328981529ccad76bbf7f293b420d6a500a8e0022
7 files changed +57 -14
src/go/plugin/go.d/collector/snmp/collect.go
+17 -12
@@ -27,13 +27,16 @@ func (c *Collector) collect() (map[string]int64, error) {
27 }
28
29 c.sysInfo = si
30 - c.addSysUptimeChart()
30
31 if c.CreateVnode {
32 c.vnode = c.setupVnode(si)
33 }
34
36 - if c.EnableProfiles {
35 + if !c.DisableLegacyCollection {
36 + c.addSysUptimeChart()
37 + }
38 +
39 + if c.DisableLegacyCollection || c.EnableProfiles {
40 c.snmpProfiles = c.setupProfiles()
41 }
42 }
@@ -44,19 +47,21 @@ func (c *Collector) collect() (map[string]int64, error) {
47 c.Infof("failed to collect profiles: %v", err)
48 }
49
47 - if err := c.collectSysUptime(mx); err != nil {
48 - return nil, err
49 - }
50 -
51 - if c.collectIfMib {
52 - if err := c.collectNetworkInterfaces(mx); err != nil {
50 + if !c.DisableLegacyCollection {
51 + if err := c.collectSysUptime(mx); err != nil {
52 return nil, err
53 }
55 - }
54
57 - if len(c.customOids) > 0 {
58 - if err := c.collectOIDs(mx); err != nil {
59 - return nil, err
55 + if c.collectIfMib {
56 + if err := c.collectNetworkInterfaces(mx); err != nil {
57 + return nil, err
58 + }
59 + }
60 +
61 + if len(c.customOids) > 0 {
62 + if err := c.collectOIDs(mx); err != nil {
63 + return nil, err
64 + }
65 }
66 }
67
src/go/plugin/go.d/collector/snmp/config.go
+1
@@ -17,6 +17,7 @@ type (
17 NetworkInterfaceFilter NetworkInterfaceFilter `yaml:"network_interface_filter,omitempty" json:"network_interface_filter"`
18 EnableProfiles bool `yaml:"enable_profiles,omitempty" json:"enable_profiles"`
19 EnableProfilesTableMetrics bool `yaml:"enable_profiles_table_metrics,omitempty" json:"enable_profiles_table_metrics"`
20 + DisableLegacyCollection bool `yaml:"disable_legacy_collection,omitempty" json:"disable_legacy_collection"`
21 }
22 NetworkInterfaceFilter struct {
23 ByName string `yaml:"by_name,omitempty" json:"by_name"`
src/go/plugin/go.d/collector/snmp/config_schema.json
+8 -1
@@ -354,6 +354,12 @@
354 "description": "Enable collection of SNMP table metrics from profiles. Enabling this may **increase collection time and memory usage** for devices with many network interfaces*",
355 "type": "boolean",
356 "default": false
357 + },
358 + "disable_legacy_collection": {
359 + "title": "Disable Legacy SNMP Collection",
360 + "description": "Disable the legacy SNMP collection method, forcing the collector to use only SNMP profiles (YAML-based configuration). When enabled, the collector will ignore any non-profile based collection logic.",
361 + "type": "boolean",
362 + "default": false
363 }
364 },
365 "required": [
@@ -481,7 +487,8 @@
487 "title": "Profiles",
488 "fields": [
489 "enable_profiles",
484 - "enable_profiles_table_metrics"
490 + "enable_profiles_table_metrics",
491 + "disable_legacy_collection"
492 ]
493 }
494 ]
src/go/plugin/go.d/collector/snmp/testdata/config.json
+2 -1
@@ -54,5 +54,6 @@
54 }
55 ],
56 "enable_profiles": true,
57 - "enable_profiles_table_metrics": true
57 + "enable_profiles_table_metrics": true,
58 + "disable_legacy_collection": true
59 }
src/go/plugin/go.d/collector/snmp/testdata/config.yaml
+1
@@ -3,6 +3,7 @@ hostname: "ok"
3 create_vnode: yes
4 enable_profiles: yes
5 enable_profiles_table_metrics: yes
6 +disable_legacy_collection: yes
7 vnode:
8 name: "ok"
9 guid: "ok"
src/go/plugin/go.d/config/go.d/snmp.profiles/default/_generic-tcp.yaml
+14
@@ -29,6 +29,13 @@ metrics:
29 description: TCP segments received
30 family: Network/TCP/Segment/Total/In
31 unit: "{packet}/s"
32 + - MIB: TCP-MIB
33 + symbol:
34 + OID: 1.3.6.1.2.1.6.10.0
35 + name: tcpInSegs
36 + description: TCP segments received
37 + family: Network/TCP/Segment/Total/In
38 + unit: "{packet}/s"
39 - MIB: TCP-MIB
40 symbol:
41 OID: 1.3.6.1.2.1.6.18.0
@@ -36,6 +43,13 @@ metrics:
43 description: TCP segments sent
44 family: Network/TCP/Segment/Total/Out
45 unit: "{packet}/s"
46 + - MIB: TCP-MIB
47 + symbol:
48 + OID: 1.3.6.1.2.1.6.11.0
49 + name: tcpOutSegs
50 + description: TCP segments sent
51 + family: Network/TCP/Segment/Total/Out
52 + unit: "{packet}/s"
53 - MIB: TCP-MIB
54 symbol:
55 OID: 1.3.6.1.2.1.6.14.0
src/go/plugin/go.d/config/go.d/snmp.profiles/default/_generic-udp.yaml
+14
@@ -8,6 +8,13 @@ metrics:
8 description: UDP datagrams received
9 family: Network/UDP/Datagram/Total/In
10 unit: "{packet}/s"
11 + - MIB: UDP-MIB
12 + symbol:
13 + OID: 1.3.6.1.2.1.7.1.0
14 + name: udpInDatagrams
15 + description: UDP datagrams received
16 + family: Network/UDP/Datagram/Total/In
17 + unit: "{packet}/s"
18 - MIB: UDP-MIB
19 symbol:
20 OID: 1.3.6.1.2.1.7.9.0
@@ -15,6 +22,13 @@ metrics:
22 description: UDP datagrams sent
23 family: Network/UDP/Datagram/Total/Out
24 unit: "{packet}/s"
25 + - MIB: UDP-MIB
26 + symbol:
27 + OID: 1.3.6.1.2.1.7.4.0
28 + name: udpOutDatagrams
29 + description: UDP datagrams sent
30 + family: Network/UDP/Datagram/Total/Out
31 + unit: "{packet}/s"
32 - MIB: UDP-MIB
33 symbol:
34 OID: 1.3.6.1.2.1.7.3.0