Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNMPv2 Expansion of Environment Variables #1145

Closed
IvoGoman opened this issue Mar 27, 2024 · 0 comments · Fixed by #1148
Closed

SNMPv2 Expansion of Environment Variables #1145

IvoGoman opened this issue Mar 27, 2024 · 0 comments · Fixed by #1148

Comments

@IvoGoman
Copy link
Contributor

IvoGoman commented Mar 27, 2024

Host operating system: output of uname -a

snmp_exporter version: output of snmp_exporter -version

current head version

What device/snmpwalk OID are you using?

not relevant

If this is a new device, please link to the MIB(s).

not relevant

What did you do that produced an error?

We are using a mix of SNMPv2 and SNMPv3 in the auth.yaml. With one device not configured with auth settings.

acistretch_v2:
  version: 2
  community: bla

This v2 module does not work as expected when using expansion of environment variables.
ts=2024-03-27T13:28:01.053Z caller=main.go:203 level=error msg="Error parsing config file" err=" environment variable not found"

The error seems to be here:

if expandEnvVars {
var err error
for i, auth := range cfg.Auths {
cfg.Auths[i].Username, err = substituteEnvVariables(auth.Username)
if err != nil {
return nil, err
}
password, err := substituteEnvVariables(string(auth.Password))
if err != nil {
return nil, err
}
cfg.Auths[i].Password.Set(password)
privPassword, err := substituteEnvVariables(string(auth.PrivPassword))
if err != nil {
return nil, err
}
cfg.Auths[i].PrivPassword.Set(privPassword)
}
}

Since the v2 configuration has no username, password or privPassword this expansion of env variables fails.

Introduced by 59194f6

What did you expect to see?

snmp-exporter does not fail parsing the env variables

What did you see instead?

the above mentionend error message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant