Skip to main content

Arista MLAG Interface State

  • January 14, 2026
  • 0 replies
  • 0 views

Forum|alt.badge.img+1

Using the MLAG_INTERFACE_STATE output that is already provided we will check the interface state in relation to all MLAG configured interfaces, this will warn if their is less than 24 hours since the last state change.

To violate the following must occur.

The state is not “active-full”

The Oper State of the interfaces on the local and remote device is not “up/up”

The configuration state is not “ena/ena”

/**
* @intent Report on the MLAG Interface State
* @description Using the show mlag interface detail command which is in commandType MLAG_INTERFACE_STATE
* the data is retrieved by calling mlagTable within the arista library. This will violate if the interface
* state does not match the expected results.
*/

//show mlag interfaces detail.

mlagInterfaces =
```
local/remote
mlag state local remote oper config last change changes
---------- ----------------- ----------- ------------ ----------- ------------- --------------------------- -------
{mlag:string} {state:string} {local:string} {remote:string} {oper:string} {config:string} {days:number} days, {time:string} ago {changes:string}
```;

export mlagTable(device: Device) =

foreach command in device.outputs.commands
where command.commandType == CommandType.MLAG_INTERFACE_STATE //Retrieve only the command show mlag interface detail
let tableResponse = command.response
let deviceName = device.name
let parsed = parseConfigBlocks(OS.UNKNOWN, tableResponse)
let tableMatches = blockMatches(parsed, mlagInterfaces)
foreach tableMatch in tableMatches
let mlag = tableMatch.data.mlag
let state = tableMatch.data.state
let local = tableMatch.data.local
let remote = tableMatch.data.remote
let operState = tableMatch.data.oper
let config = tableMatch.data.config
let mlagDays = tableMatch.data.days
let mlagTime = tableMatch.data.time
let changes = tableMatch.data.changes
let returnData = {mlag,state,local,remote,operState,config,mlagDays,mlagTime,changes}
select(returnData);

foreach device in network.devices

where device.platform.os == OS.ARISTA_EOS
// Retrieve vxlan Sanity from Arista Library.
let mlagTable = mlagTable(device)
let deviceName = device.name
foreach item in mlagTable
// Retrieve fields from table which we will process.
let state = item.state
let operState = item.operState
let config = item.config
let lastChangeDays = item.mlagDays
let lastChangeDuration = item.mlagTime
let StateOk = if state == "active-full" then true else false
let OperOk = if operState == "up/up" then true else false
let configOk = if config == "ena/ena" then true else false
// Check if there has been a change in the last 24 hours which would indicate a recent change since the last snapshot
let RecentChange = if lastChangeDays == 0 then true else false

// Build Output text and state
let resultOutput = ""
let resultOutput = if !StateOk
then if resultOutput == ""
then "State is not Active/Full"
else resultOutput+", State is not Active/Full"
else if !OperOk
then if resultOutput == ""
then "Operational Status of the ports is not up/up"
else resultOutput+", Operational Status of the ports is not up/up"
else if !configOk
then if resultOutput == ""
then "Config State is not enabled on local and remote device"
else resultOutput+", Config State is not enabled on local and remote device"
else if RecentChange
then if resultOutput == ""
then "Warning: Recent Change in MLAG State for interface"
else resultOutput + ", Warning: Recent Change in MLAG State for interface"
else resultOutput // Catchall do not change output if no issues.
//Now lets violation if any of the values is not ok.
let violation = if !StateOk || !OperOk || !configOk then true else false

//Now set the pretty Status message.
let resultState = if violation
then withInfoStatus("ERROR",InfoStatus.ERROR)
else if RecentChange
then withInfoStatus("WARN",InfoStatus.WARNING)
else withInfoStatus("OK",InfoStatus.OK)

select {
Name:deviceName,
result:resultState,
message:resultOutput,
mlag:item.mlag,
state:state,
local_port:item.local,
remote_port:item.remote,
operating_state:operState,
config:config,
lastChangeNoOfDays:lastChangeDays,
lastChangeHHMMSS:lastChangeDuration,
No_Of_Changes:item.changes,
violation:violation
}