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

snmp: return error on unknown conversion type #1853

Merged
merged 1 commit into from
Oct 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/inputs/snmp/snmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,6 @@ func (s *Snmp) getConnection(agent string) (snmpConnection, error) {
// "hwaddr" will convert the value into a MAC address.
// "ipaddr" will convert the value into into an IP address.
// "" will convert a byte slice into a string.
// Any other conv will return the input value unchanged.
func fieldConvert(conv string, v interface{}) (interface{}, error) {
if conv == "" {
if bs, ok := v.([]byte); ok {
Expand Down Expand Up @@ -805,6 +804,7 @@ func fieldConvert(conv string, v interface{}) (interface{}, error) {
default:
return nil, fmt.Errorf("invalid type (%T) for hwaddr conversion", v)
}
return v, nil
}

if conv == "ipaddr" {
Expand All @@ -829,7 +829,7 @@ func fieldConvert(conv string, v interface{}) (interface{}, error) {
return v, nil
}

return v, nil
return nil, fmt.Errorf("invalid conversion type '%s'", conv)
}

// snmpTranslate resolves the given OID.
Expand Down