Skip to main content

This is a check I wrote to check BFD Status on Arista and IOS-XE as a single combined query. Unfortunately, I can’t change the name of the title to include Arista && IOS-XE

  • screenShot
/**
* @intent BFD State Arista & IOS-XE
* @description Add Command 'show bfd neighbors || peers' and report status - apply to EOS and IOX-XE Devices
**/

EOS_BFDPattern = ```
{DstAddr:ipv4Address} {MyDisc:number} {YourDisc:string} {Interface:string} {Type:string} {LastUp:string} {LastDown:string} {LastDiag:string} {State1:string} {State2:string} {State3:string} {State4:string}
```;

iosXE_BFDPattern = ```
{ip:ipv4Address} {LD:string} {RD:string} {State:string} {Int1:string}
```;

// Define EOS Function
Arista_BFD =
foreach Device in network.devices
let Platform = Device.platform
where Platform.os == OS.ARISTA_EOS
let Outputs = Device.outputs
foreach Command in Outputs.commands
where Command.commandText == "show bfd peers"
let parsed = parseConfigBlocks(OS.ARISTA_EOS, Command.response)
let matchData = blockMatches(parsed, EOS_BFDPattern)

foreach x in matchData
select{
name:Device.name,
model:Platform.os,
IP:x.data.DstAddr,
Intf:x.data.Interface,
State:x.data.State4
};

// Define IOSXE Function
IOSXE_BFD =
foreach Device in network.devices
let Platform = Device.platform
where Platform.os == OS.IOS_XE
let Outputs = Device.outputs
foreach Command in Outputs.commands
where Command.commandText == "show bfd neighbors"
let parsed = parseConfigBlocks(OS.IOS_XE, Command.response) //parses text into lines
let matchData = blockMatches(parsed, iosXE_BFDPattern) //applies pattern to lines

foreach x in matchData
select{
name:Device.name,
model:Platform.os,
IP:x.data.ip,
Intf:x.data.Int1,
State:x.data.State
};

//Combine Functions
osList = IOSXE_BFD + Arista_BFD;

// Unify Tables
foreach result in osList
select{
Hostname:result.name,
Model:result.model,
Neighbor:result.IP,
Intf:result.Intf,
State:result.State
}

If you have any questions or enhancements, please reach out!

rcariddi@gmail.com

IOS_XE CVE-2023-20198 check related here: 

 


Reply