@cryptotaxi247 / netdata-1 / commits / 956258691

fix(go.d/sd/snmp): fix snmnpv3 again (#20256)

Ilya Mashchenko committed May 8, 2025 at 14:41 UTC 9562586917d049b060b86003568d0212992125db
3 files changed +29 -29
src/go/plugin/go.d/agent/discovery/sd/discoverer/snmpsd/config.go
+6 -6
@@ -49,12 +49,12 @@ type (
49 SecurityLevel string `yaml:"security_level"`
50 // AuthProtocol must be one of: "md5", "sha", "sha224", "sha256", "sha384", "sha512" (for SNMPv3)
51 AuthProtocol string `yaml:"auth_protocol"`
52 - // AuthPassword is the authentication passphrase (for SNMPv3)
53 - AuthPassword string `yaml:"auth_password"`
52 + // AuthPassphrase is the authentication passphrase (for SNMPv3)
53 + AuthPassphrase string `yaml:"auth_password"`
54 // PrivacyProtocol must be one of: "des", "aes", "aes192", "aes256", "aes192C", "aes256C" (for SNMPv3)
55 PrivacyProtocol string `yaml:"priv_protocol"`
56 - // PrivacyPassword is the privacy passphrase (for SNMPv3)
57 - PrivacyPassword string `yaml:"priv_password"`
56 + // PrivacyPassphrase is the privacy passphrase (for SNMPv3)
57 + PrivacyPassphrase string `yaml:"priv_password"`
58 }
59 )
60
@@ -136,9 +136,9 @@ func setCredential(client gosnmp.Handler, cred CredentialConfig) {
136 client.SetSecurityParameters(&gosnmp.UsmSecurityParameters{
137 UserName: cred.UserName,
138 AuthenticationProtocol: parseSNMPv3AuthProtocol(cred),
139 - AuthenticationPassphrase: cred.AuthPassword,
139 + AuthenticationPassphrase: cred.AuthPassphrase,
140 PrivacyProtocol: parseSNMPv3PrivProtocol(cred),
141 - PrivacyPassphrase: cred.PrivacyPassword,
141 + PrivacyPassphrase: cred.PrivacyPassphrase,
142 })
143 }
144 }
src/go/plugin/go.d/agent/discovery/sd/discoverer/snmpsd/discoverer_test.go
+16 -16
@@ -45,14 +45,14 @@ func TestNewDiscoverer(t *testing.T) {
45 cfg: Config{
46 Credentials: []CredentialConfig{
47 {
48 - Name: "v3cred",
49 - Version: "3",
50 - UserName: "user",
51 - SecurityLevel: "authPriv",
52 - AuthProtocol: "sha",
53 - AuthPassword: "authpass",
54 - PrivacyProtocol: "aes",
55 - PrivacyPassword: "privpass",
48 + Name: "v3cred",
49 + Version: "3",
50 + UserName: "user",
51 + SecurityLevel: "authPriv",
52 + AuthProtocol: "sha",
53 + AuthPassphrase: "authpass",
54 + PrivacyProtocol: "aes",
55 + PrivacyPassphrase: "privpass",
56 },
57 },
58 Networks: []NetworkConfig{
@@ -66,14 +66,14 @@ func TestNewDiscoverer(t *testing.T) {
66 {Name: "v1cred", Version: "1", Community: "public"},
67 {Name: "v2cred", Version: "2c", Community: "private"},
68 {
69 - Name: "v3cred",
70 - Version: "3",
71 - UserName: "user",
72 - SecurityLevel: "authPriv",
73 - AuthProtocol: "sha",
74 - AuthPassword: "authpass",
75 - PrivacyProtocol: "aes",
76 - PrivacyPassword: "privpass",
69 + Name: "v3cred",
70 + Version: "3",
71 + UserName: "user",
72 + SecurityLevel: "authPriv",
73 + AuthProtocol: "sha",
74 + AuthPassphrase: "authpass",
75 + PrivacyProtocol: "aes",
76 + PrivacyPassphrase: "privpass",
77 },
78 },
79 Networks: []NetworkConfig{
src/go/plugin/go.d/config/go.d/sd/snmp.conf
+7 -7
@@ -90,11 +90,11 @@ compose:
90 {{- if eq .Credential.Version "1" "2" }}
91 community: {{ .Credential.Community }}
92 {{- else }}
93 - user:
94 - name: {{ .Credential.UserName }}
95 - level: {{ .Credential.SecurityLevel }}
96 - auth_proto: {{ .Credential.AuthProtocol }}
97 - auth_key: {{ .Credential.AuthPassphrase }}
98 - priv_proto: {{ .Credential.PrivacyProtocol }}
99 - priv_key: {{ .Credential.PrivacyPassphrase }}
93 + user:
94 + name: {{ .Credential.UserName }}
95 + level: {{ .Credential.SecurityLevel }}
96 + auth_proto: {{ .Credential.AuthProtocol }}
97 + auth_key: {{ .Credential.AuthPassphrase }}
98 + priv_proto: {{ .Credential.PrivacyProtocol }}
99 + priv_key: {{ .Credential.PrivacyPassphrase }}
100 {{- end }}