-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I82d8ba6d96ab8403137ac493ea96e4ff2a1fcfff
- Loading branch information
1 parent
8555880
commit ec05318
Showing
10 changed files
with
317 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
333 changes: 162 additions & 171 deletions
333
docsrc/examples/layer2_and_layer3/webinar03_bgp_states.json
Large diffs are not rendered by default.
Oops, something went wrong.
37 changes: 20 additions & 17 deletions
37
docsrc/examples/layer2_and_layer3/webinar03_bgp_states_bgp_flaps.aql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
let devices = merge(`analytics:/tags/labels/devices/pod_name/value/<_POD_NAME>/elements`) | ||
|
||
if str(_POD_NAME) == "" { | ||
let data =`analytics:/Devices/*/versioned-data/routing/bgp/status/vrf/default/bgpPeerInfoStatusEntry/*`[4h] | ||
} else { | ||
let data =`analytics:/Devices/*/versioned-data/routing/bgp/status/vrf/default/bgpPeerInfoStatusEntry/*`[4h] | where(dictHasKey(devices, complexKey("{\"deviceID\": \""+_key+"\"}"))) | ||
} | ||
|
||
let data =`analytics:/Devices/*/versioned-data/routing/bgp/status/vrf/default/bgpPeerInfoStatusEntry/*`[24h] | ||
let devices = merge(`analytics:/tags/labels/devices/site_name/value/<_SITE_NAME>/elements`) | ||
let data = data | where(dictHasKey(devices, complexKey("{\"deviceID\": \""+_key+"\"}"))) | ||
let result = newDict() | ||
for sn, deviceValues in data{ | ||
let count = 0 | ||
for ip, tseries in deviceValues{ | ||
for timestamp, values in tseries { | ||
if dictHasKey(values, "bgpState"){ | ||
if values["bgpState"]["Name"] == "Established"{ | ||
let count = count +1 | ||
|
||
for device, deviceValues in data { | ||
let establishedNeighbors = newDict() | ||
let flapCount = 0 | ||
for ip, tseries in deviceValues{ | ||
for timestamp, values in tseries { | ||
if dictHasKey(values, "bgpState"){ | ||
if values["bgpState"]["Name"] == "Established"{ | ||
let flapCount = flapCount +1 | ||
establishedNeighbors[ip] = true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
result[sn] = newDict() | setFields("Flaps", count-1) | ||
let count = flapCount - length(establishedNeighbors) | ||
if count > 0 { | ||
result[device] = newDict() | setFields("Flaps", count ) | ||
} | ||
|
||
} | ||
|
||
result |
96 changes: 63 additions & 33 deletions
96
docsrc/examples/layer2_and_layer3/webinar03_bgp_states_bgp_sum.aql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,78 @@ | ||
let devices = merge(`analytics:/tags/labels/devices/pod_name/value/<_POD_NAME>/elements`) | ||
let bgpPeerInfoStatusEntry = `*:/Sysdb/cell/1/routing/bgp/export/vrfBgpPeerInfoStatusEntryTable/default/bgpPeerInfoStatusEntry/*` | ||
if str(_POD_NAME) == "" { | ||
let bgpNeighbors =`analytics:/Devices/*/versioned-data/routing/bgp/status/vrf/default/bgpPeerInfoStatusEntry/*` | ||
} else { | ||
let bgpNeighbors =`analytics:/Devices/*/versioned-data/routing/bgp/status/vrf/default/bgpPeerInfoStatusEntry/*` | where(dictHasKey(devices, complexKey("{\"deviceID\": \""+_key+"\"}"))) | ||
} | ||
let bgpPeerStatisticsEntry = `*:/Smash/routing/bgp/bgpPeerInfoStatus/default/bgpPeerStatisticsEntry` | ||
# set vars | ||
let afis = newDict() | ||
let afi_name = newDict() | ||
let bgpPeerAfiSafiActive = newDict() | setFields("l2vpnEvpn", 3, "ipv4Unicast", 1) | ||
let bgpPeerAfiSafiActiveName = newDict() | setFields("l2vpnEvpn","L2VPN EVPN", "ipv4Unicast", "IPv4 Unicast") | ||
|
||
# Get all devices from a specific site | ||
let devices = merge(`analytics:/tags/labels/devices/site_name/value/<_SITE_NAME>/elements`) | ||
|
||
let bgpNeighbors =`analytics:/Devices/*/versioned-data/routing/bgp/status/vrf/*/bgpPeerInfoStatusEntry/*` | ||
if _device != "" { | ||
let bgpNeighbors = bgpNeighbors | fields(_device) | ||
} else { | ||
if str(_SITE_NAME) != "" { | ||
let bgpNeighbors = bgpNeighbors | where(dictHasKey(devices, complexKey("{\"deviceID\": \""+_key+"\"}"))) | ||
} | ||
} | ||
|
||
let bgpPeerInfoStatusEntry = `*:/Sysdb/cell/1/routing/bgp/export/vrfBgpPeerInfoStatusEntryTable/*/bgpPeerInfoStatusEntry/*` | ||
let bgpPeerStatisticsEntry = `*:/Smash/routing/bgp/bgpPeerInfoStatus/*/bgpPeerStatisticsEntry` | ||
|
||
# This is the table | ||
let result = newDict() | ||
let id = 0 | ||
# Lets loop over every device | ||
for device, deviceSessions in bgpNeighbors{ | ||
for deviceKey, deviceSessions in bgpNeighbors{ | ||
# And each session on the devices | ||
for ip, sessionData in deviceSessions{ | ||
let data = merge(sessionData) | ||
# Add one to the ID | ||
let id = id + 1 | ||
result[id] = newDict() | ||
# This is where we add the various columns | ||
result[id]["0. Device"] = device | ||
result[id]["1. Status"] = data["bgpState"]["Name"] | ||
result[id]["2. Peering Address"] = data["bgpPeerLocalAddr"] | ||
result[id]["3. Neighbor Address"] = data["key"] | ||
result[id]["4. Neighbor AS"] = data["bgpPeerAs"]["value"] | ||
if dictHasKey(bgpPeerInfoStatusEntry, device) && dictHasKey(bgpPeerStatisticsEntry, device) { | ||
let test = merge(bgpPeerInfoStatusEntry[device][ip]) | ||
for kafi, kval in test["bgpPeerAfiSafiActive"]{ | ||
if kval == true { | ||
afis[device] = bgpPeerAfiSafiActive[kafi] | ||
afi_name[device] = bgpPeerAfiSafiActiveName[kafi] | ||
if _device == "" || deviceKey == _device { | ||
for vrfKey, vrfValue in deviceSessions{ | ||
# Check if _vrf is empty or if the current vrfKey is in _vrf | ||
if length(_vrf) == 0 || _vrf == vrfKey { | ||
for ip, sessionData in vrfValue { | ||
let data = merge(sessionData) | ||
# Add one to the ID | ||
let id = id + 1 | ||
result[id] = newDict() | ||
# This is where we add the various columns | ||
result[id]["0. Device"] = deviceKey | ||
result[id]["1. Status"] = data["bgpState"]["Name"] | ||
result[id]["2. Peering Address"] = data["bgpPeerLocalAddr"] | ||
result[id]["3. Neighbor Address"] = data["key"] | ||
result[id]["4. Neighbor AS"] = data["bgpPeerAs"]["value"] | ||
result[id]["6. VRF"] = vrfKey | ||
if dictHasKey(bgpPeerInfoStatusEntry, deviceKey) && dictHasKey(bgpPeerStatisticsEntry, deviceKey) { | ||
if dictHasKey(bgpPeerInfoStatusEntry[deviceKey], vrfKey) { | ||
let test = merge(bgpPeerInfoStatusEntry[deviceKey][vrfKey][ip]) | ||
for kafi, kval in test["bgpPeerAfiSafiActive"]{ | ||
if kval == true { | ||
afis[deviceKey] = bgpPeerAfiSafiActive[kafi] | ||
afi_name[deviceKey] = bgpPeerAfiSafiActiveName[kafi] | ||
result[id]["7. AFI/SAFI"] = afi_name[deviceKey] | ||
} | ||
} | ||
result[id]["5. Peer Description"] = test["bgpPeerDescription"] | ||
} | ||
if dictHasKey(bgpPeerStatisticsEntry[deviceKey], vrfKey) { | ||
let bgpPeerAfiSafiStats = merge(bgpPeerStatisticsEntry[deviceKey][vrfKey]) | ||
if dictHasKey(afis, deviceKey) && dictHasKey(bgpPeerAfiSafiStats, ip){ | ||
result[id]["8. PfxRcd"] = bgpPeerAfiSafiStats[ip]["bgpPeerAfiSafiStats"][afis[deviceKey]]["prefixIn"] | ||
result[id]["9. PfxAcc"] = bgpPeerAfiSafiStats[ip]["bgpPeerAfiSafiStats"][afis[deviceKey]]["prefixAcceptedIn"] | ||
} | ||
} | ||
|
||
|
||
} else { | ||
# need to figure out why sometimes there's no prefix info | ||
result[id]["8. PfxRcd"] = "N/A" | ||
result[id]["9. PfxAcc"] = "N/A" | ||
} | ||
if dictHasKey(data, "bgpPeerIntoOrOutOfEstablishedTime") { | ||
result[id]["10. Up/Down"] = str(duration(1000000000*round(num(now() - time(data["bgpPeerIntoOrOutOfEstablishedTime"]*1000000000))/1000000000))) | ||
} | ||
} | ||
} | ||
let bgpPeerAfiSafiStats = merge(bgpPeerStatisticsEntry[device]) | ||
if dictHasKey(afis, device){ | ||
result[id]["6. PfxRcd"] = bgpPeerAfiSafiStats[ip]["bgpPeerAfiSafiStats"][afis[device]]["prefixIn"] | ||
result[id]["7. PfxAcc"] = bgpPeerAfiSafiStats[ip]["bgpPeerAfiSafiStats"][afis[device]]["prefixAcceptedIn"] | ||
} | ||
result[id]["8. Up/Down"] = str(duration(1000000000*round(num(now() - time(data["bgpPeerIntoOrOutOfEstablishedTime"]*1000000000))/1000000000))) | ||
} | ||
} | ||
} | ||
result | ||
result |
8 changes: 4 additions & 4 deletions
8
docsrc/examples/layer2_and_layer3/webinar03_bgp_states_bgp_syslogs.aql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
let data = `<_bgpDevice>:/Logs/var/log/messages`[4h] | field("line") | where(reMatch(_value, "BGP")) | ||
let data = `<_bgpDevice>:/Logs/var/log/messages`[48h] | field("line") | where(reMatch(_value, "BGP")) | ||
let logs = newDict() | ||
for timest, logentry in data { | ||
logs[str(timest)] = newDict() | ||
logs[str(timest)]["Log"] = logentry | ||
logs[str(timest+(_tz_offset))] = newDict() | ||
logs[str(timest+(_tz_offset))]["Log"] = logentry | ||
} | ||
logs | ||
logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.