feat(go.d/snmp): add configurable device down threshold for vnodes (#20770)
Ilya Mashchenko committed
Aug 6, 2025 at 15:47 UTC
d7e7f751d89cd6f861b46a223c071d53b01d6bee
7 files changed
+23
src/go/plugin/go.d/collector/snmp/collect.go
+7
@@ -9,6 +9,7 @@ import (
9
"maps"
10
"path/filepath"
11
"slices"
12
+ "strconv"
13
"strings"
14
15
"github.com/google/uuid"
@@ -123,6 +124,12 @@ func (c *Collector) setupVnode(si *snmpsd.SysInfo, deviceMeta map[string]map[str
124
"address": c.Hostname,
125
}
126
127
+ if c.UpdateEvery >= 1 && c.VnodeDeviceDownThreshold >= 1 {
128
+ // Add 2 seconds buffer to account for collection/transmission delays
129
+ v := c.VnodeDeviceDownThreshold*c.UpdateEvery + 2
130
+ labels["_node_stale_after_seconds"] = strconv.Itoa(v)
131
+ }
132
+
133
maps.Copy(labels, c.Vnode.Labels)
134
for _, meta := range deviceMeta {
135
maps.Copy(labels, meta)
src/go/plugin/go.d/collector/snmp/collector.go
+1
@@ -44,6 +44,7 @@ func New() *Collector {
44
CreateVnode: true,
45
EnableProfiles: true,
46
EnableProfilesTableMetrics: true,
47
+ VnodeDeviceDownThreshold: 3,
48
Options: Options{
49
Port: 161,
50
Retries: 1,
src/go/plugin/go.d/collector/snmp/config.go
+1
@@ -9,6 +9,7 @@ type (
9
UpdateEvery int `yaml:"update_every,omitempty" json:"update_every"`
10
Hostname string `yaml:"hostname" json:"hostname"`
11
CreateVnode bool `yaml:"create_vnode,omitempty" json:"create_vnode"`
12
+ VnodeDeviceDownThreshold int `yaml:"vnode_device_down_threshold,omitempty" json:"vnode_device_down_threshold"`
13
Vnode vnodes.VirtualNode `yaml:"vnode,omitempty" json:"vnode"`
14
Community string `yaml:"community,omitempty" json:"community"`
15
User User `yaml:"user,omitempty" json:"user"`
src/go/plugin/go.d/collector/snmp/config_schema.json
+8
@@ -27,6 +27,13 @@
27
"type": "boolean",
28
"default": true
29
},
30
+ "vnode_device_down_threshold": {
31
+ "title": "Device Down Threshold",
32
+ "description": "Number of consecutive failed data collections before marking the device as down.",
33
+ "type": "integer",
34
+ "minimum": 1,
35
+ "default": 3
36
+ },
37
"vnode": {
38
"title": "Configuration",
39
"description": "",
@@ -458,6 +465,7 @@
465
"title": "Vnode",
466
"fields": [
467
"create_vnode",
468
+ "vnode_device_down_threshold",
469
"vnode"
470
]
471
},
src/go/plugin/go.d/collector/snmp/metadata.yaml
+4
@@ -109,6 +109,10 @@ modules:
109
description: If set, the collector will create a Netdata Virtual Node for this SNMP device, which will appear as a separate Node in Netdata.
110
default_value: "true"
111
required: false
112
+ - name: vnode_device_down_threshold
113
+ description: Number of consecutive failed data collections before marking the device as down.
114
+ default_value: 3
115
+ required: false
116
- name: vnode.guid
117
description: A unique identifier for the Virtual Node. If not set, a GUID will be automatically generated from the device's IP address.
118
default_value: ""
src/go/plugin/go.d/collector/snmp/testdata/config.json
+1
@@ -2,6 +2,7 @@
2
"update_every": 123,
3
"hostname": "ok",
4
"create_vnode": true,
5
+ "vnode_device_down_threshold": 123,
6
"vnode": {
7
"name": "ok",
8
"guid": "ok",
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
+vnode_device_down_threshold: 123
5
enable_profiles: yes
6
enable_profiles_table_metrics: yes
7
disable_legacy_collection: yes