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

fixing a case where some oid values do not get matched in disco #773

Merged
merged 1 commit into from
Nov 6, 2024
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
30 changes: 22 additions & 8 deletions pkg/inputs/snmp/metadata/device_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,17 @@ func (dm *DeviceMetadata) poll(ctx context.Context, server *gosnmp.GoSNMP) (*kt.
case SNMP_sysDescr:
md.SysDescr = string(value.([]byte))
case SNMP_sysObjectID:
if s, ok := value.(string); ok {
md.SysObjectID = s
} else if s, ok := value.([]byte); ok {
md.SysObjectID = string(s)
switch sd := value.(type) {
case string:
md.SysObjectID = sd
case []byte:
md.SysObjectID = string(sd)
default:
if wrapper.variable.Type == gosnmp.ObjectIdentifier {
md.SysObjectID = string(sd.(string))
} else {
dm.log.Warnf("Unknown type for sysoid: %v %T", value, value)
}
}
case SNMP_sysContact:
md.SysContact = string(value.([]byte))
Expand Down Expand Up @@ -319,10 +326,17 @@ func GetBasicDeviceMetadata(log logger.ContextL, server *gosnmp.GoSNMP) (*kt.Dev
case SNMP_sysDescr:
md.SysDescr = string(value.([]byte))
case SNMP_sysObjectID:
if s, ok := value.(string); ok {
md.SysObjectID = s
} else if s, ok := value.([]byte); ok {
md.SysObjectID = string(s)
switch sd := value.(type) {
case string:
md.SysObjectID = sd
case []byte:
md.SysObjectID = string(sd)
default:
if pdu.Type == gosnmp.ObjectIdentifier {
md.SysObjectID = string(sd.(string))
} else {
log.Warnf("Unknown type for sysoid: %v %T", value, value)
}
}
case SNMP_sysContact:
md.SysContact = string(value.([]byte))
Expand Down
Loading