Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions snmp-discovery/mapping/mappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ func (m *InterfaceMapper) Map(values map[ObjectIDIndex]*ObjectIDValue, mappingEn
case "name":
interfaceEntity.Name = &value.Value
fieldFound = true
case "description":
description := strings.TrimRight(value.Value, " \t\n\r")
if len(description) > 200 {
description = description[:197] + "..."
}
interfaceEntity.Description = &description
fieldFound = true
case "type":
defaultType := ""
if defaults != nil && defaults.Interface.Type != "" {
Expand Down
13 changes: 13 additions & 0 deletions snmp-discovery/mapping/mappers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@ func TestInterfaceMapper_Map(t *testing.T) {
Value: "1",
Type: mapping.Integer,
},
"1.3.6.1.2.1.31.1.1.1.18.1": {
OID: "1.3.6.1.2.1.31.1.1.1.18.1",
Index: "1",
Parent: "1.3.6.1.2.1.31.1.1.1.18",
Value: "uplink interface",
Type: mapping.OctetString,
},
},
mappingEntry: &mapping.Entry{
OID: "1.3.6.1.2.1.2.2.1.1",
Expand Down Expand Up @@ -424,6 +431,11 @@ func TestInterfaceMapper_Map(t *testing.T) {
Entity: "interface",
Field: "adminStatus",
},
{
OID: "1.3.6.1.2.1.31.1.1.1.18",
Entity: "interface",
Field: "description",
},
},
},
defaults: nil,
Expand All @@ -433,6 +445,7 @@ func TestInterfaceMapper_Map(t *testing.T) {
Mtu: int64Ptr(1500),
PrimaryMacAddress: &diode.MACAddress{MacAddress: mapping.StringPtr("00:11:22:33:44:55")},
Enabled: boolPtr(true),
Description: mapping.StringPtr("uplink interface"),
},
expectError: false,
},
Expand Down
3 changes: 3 additions & 0 deletions snmp-discovery/policy/mapping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ entries:
- oid: ".1.3.6.1.2.1.2.2.1.7"
entity: "interface"
field: "adminStatus"
- oid: ".1.3.6.1.2.1.31.1.1.1.18"
entity: "interface"
field: "description"

# IP Address mappings
- oid: ".1.3.6.1.2.1.4.20.1"
Expand Down
Loading