fix(go.d/sd/snmp): use rescan and cache ttl only when set (#19760)
Ilya Mashchenko committed
Mar 3, 2025 at 23:52 UTC
3f064a0c50021d85138d98161a0dc8af32cd51f4
2 files changed
+4
-4
src/go/plugin/go.d/agent/discovery/sd/discoverer/snmpsd/config.go
+2
-2
@@ -14,11 +14,11 @@ import (
14
type (
15
Config struct {
16
// RescanInterval defines how often to scan the networks for devices (default: 30m)
17
- RescanInterval confopt.Duration `yaml:"rescan_interval"`
17
+ RescanInterval *confopt.Duration `yaml:"rescan_interval"`
18
// Timeout defines the maximum time to wait for SNMP device responses (default: 1s)
19
Timeout confopt.Duration `yaml:"timeout"`
20
// DeviceCacheTTL defines how long to trust cached discovery results before requiring a new probe (default: 12h)
21
- DeviceCacheTTL confopt.Duration `yaml:"device_cache_ttl"`
21
+ DeviceCacheTTL *confopt.Duration `yaml:"device_cache_ttl"`
22
// ParallelScansPerNetwork defines how many IPs to scan concurrently within each subnet (default: 32)
23
ParallelScansPerNetwork int `yaml:"parallel_scans_per_network"`
24
// Credentials define the SNMP credentials used for authentication
src/go/plugin/go.d/agent/discovery/sd/discoverer/snmpsd/discoverer.go
+2
-2
@@ -54,7 +54,7 @@ func NewDiscoverer(cfg Config) (*Discoverer, error) {
54
status: newDiscoveryStatus(),
55
}
56
57
- if cfg.RescanInterval >= 0 {
57
+ if cfg.RescanInterval != nil && *cfg.RescanInterval >= 0 {
58
d.rescanInterval = cfg.RescanInterval.Duration()
59
}
60
if cfg.Timeout > 0 {
@@ -63,7 +63,7 @@ func NewDiscoverer(cfg Config) (*Discoverer, error) {
63
if cfg.ParallelScansPerNetwork > 0 {
64
d.parallelScansPerNetwork = cfg.ParallelScansPerNetwork
65
}
66
- if cfg.DeviceCacheTTL >= 0 {
66
+ if cfg.DeviceCacheTTL != nil && *cfg.DeviceCacheTTL >= 0 {
67
d.deviceCacheTTL = cfg.DeviceCacheTTL.Duration()
68
}
69