Skip to content

Commit

Permalink
[corechecks/snmp] Add id and source_type to Topology Links data (#…
Browse files Browse the repository at this point in the history
…15184)

Co-authored-by: pducolin <[email protected]>
  • Loading branch information
AlexandreYang and pducolin authored Jan 20, 2023
1 parent e7a6c9b commit e0d3077
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/collector/corechecks/snmp/internal/metadata/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ type TopologyLinkSide struct {

// TopologyLinkMetadata contains topology interface to interface links metadata
type TopologyLinkMetadata struct {
Local *TopologyLinkSide `json:"local,omitempty"`
Remote *TopologyLinkSide `json:"remote,omitempty"`
ID string `json:"id"`
SourceType string `json:"source_type"`
Local *TopologyLinkSide `json:"local"`
Remote *TopologyLinkSide `json:"remote"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
)

const interfaceStatusMetric = "snmp.interface.status"
const topologyLinkSourceTypeLLDP = "lldp"

// ReportNetworkDeviceMetadata reports device metadata
func (ms *MetricSender) ReportNetworkDeviceMetadata(config *checkconfig.CheckConfig, store *valuestore.ResultValueStore, origTags []string, collectTime time.Time, deviceStatus metadata.DeviceStatus) {
Expand Down Expand Up @@ -306,7 +307,13 @@ func buildNetworkTopologyMetadata(deviceID string, store *metadata.Store, interf

localInterfaceIDType, localInterfaceID = resolveLocalInterface(deviceID, interfaceIndexByIDType, localInterfaceIDType, localInterfaceID)

// remEntryUniqueID: The combination of localPortNum and lldpRemIndex is expected to be unique for each entry in
// lldpRemTable. We don't include lldpRemTimeMark (used for filtering only recent data) since it can change often.
remEntryUniqueID := localPortNum + "." + lldpRemIndex

newLink := metadata.TopologyLinkMetadata{
ID: deviceID + ":" + remEntryUniqueID,
SourceType: topologyLinkSourceTypeLLDP,
Remote: &metadata.TopologyLinkSide{
Device: &metadata.TopologyLinkDevice{
Name: store.GetColumnAsString("lldp_remote.device_name", strIndex),
Expand Down
4 changes: 4 additions & 0 deletions pkg/collector/corechecks/snmp/profile_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ profiles:
],
"links": [
{
"id": "profile-metadata:1.2.3.4:101.1",
"source_type": "lldp",
"local": {
"device": {
"id": "profile-metadata:1.2.3.4",
Expand All @@ -590,6 +592,8 @@ profiles:
}
},
{
"id": "profile-metadata:1.2.3.4:102.2",
"source_type": "lldp",
"local": {
"device": {
"id": "profile-metadata:1.2.3.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Each section from every release note are combined when the
# CHANGELOG.rst is rendered. So the text needs to be worded so that
# it does not depend on any information only available in another
# section. This may mean repeating some details, but each section
# must be readable independently of the other.
#
# Each section note must be formatted as reStructuredText.
---
enhancements:
- |
[corechecks/snmp] Add `id` and `source_type` to NDM Topology Links

0 comments on commit e0d3077

Please sign in to comment.