Sorry about the lack of punctuation in the title, I can’t edit after ;-)
So I don’t know if this is possible, but maybe someone has an idea.
The script below provides the following output:
The goal of the script is to figure out how ‘over provisioned’ we are on a switch. i.e. how many ports have never passed a packet. This is in order to size environments better for future refreshes.
So the output provides all the necessary info, but I’m not sure how to get a row to tell me “% Utililized”
This would be the total count of the ports in use (last column) divided into the the number of ports that specific switch, that show “0” across the board, and I’ll just take 1 zero and assume the rest are zeros (sometimes they are not, but this is just an estimate anyway).
Any ideas are greatly appreicated.
/**
* @intent Branch Counters
* @description Branch Counters Interface Status show int counters on Arista & IOS-XE Switches
* 1. Check to see what switch ports have had no traffic accross the wire for sizing and planning.
* 2. Match on platform.os
* 3. Use the information from the custom command 'show int counters'.
* 4. Get port Status and number of ports on that switch
**/
// Pattern of output
// Arista & Cisco have same pattern/columns
Traffic =
```
{Port:string} {InOctets:number} {InUcastPkts:number} {InMcastPkts:number} {InBcastPkts:number}
```;
foreach device in network.devices
where "Branch" in device.tagNames && "AMRS" in device.tagNames && "Access" in device.tagNames
where device.platform.vendor == Vendor.CISCO || device.platform.os == OS.ARISTA_EOS
foreach command in device.outputs.commands
where command.commandText == "sh int counters"
let parsed = parseConfigBlocks(device.platform.os, command.response)
let matchData = blockMatches(parsed, Traffic)
foreach iface in device.interfaces
// get 1 match per interface
let x = max(foreach y in matchData
where iface.name == toLowerCase(y.data.Port)
select y)
where isPresent(x)
select {
Location: device.locationName,
name: device.name,
Vendor: device.platform.vendor,
Model: device.platform.model,
OS: device.platform.os,
Tag: device.tagNames,
Port: iface.name,
OperStatus: iface.operStatus,
Description: iface.description,
InUcastPkts: x.data.InUcastPkts,
InMcastPkts: x.data.InMcastPkts,
InBcastPkts: x.data.InBcastPkts,
InterfaceCount: length(device.interfaces),
}