Skip to main content

Arista show mlag status detailed NQE

  • January 9, 2026
  • 0 replies
  • 7 views

Forum|alt.badge.img+1

This NQE uses the show mlag detail command which all that it should be in command.type of MLAG_STATE it did not appear so I added it as a custom command and will violate if the following occur:

What I alert on:

Mlag state is not Acitve

Negotiate Status is not connected

Peer Config is not Consistent

Peer Link and/or local interface are not up

If both the local and peer device are both primary or both secondary admittedly the latter may be impossible but though of capturing it just in case 

Peer Link is error disabled.

If the Agent is not showing as ruinning.

What we warn on:

We will also Warn on the following:

If there any ports disabled, Inactive or Active Partial

If the number of port disabled, inactive or Active partial is the same as the total number of ports configured.

 

/**
* @intent Check the MLAG status
* @description Using the AristaMLAGDetail function in the Arista Library check to verify the status is as expected
*
* This query also uses the violationProcessing function from the Utilities Library to build the violation message
* returned on violation
*/

//Show mlag detailed output.
mlagOutput =
```
MLAG Configuration:
domain-id : {MLAGDomain:string}
local-interface : {LocalInterface:string}
peer-address : {PeerAddress:string}
peer-link : {PeerLink:string}
hb-peer-address : {hbPeerAddress:string}
peer-config : {PeerConfig:string}

MLAG Status:
state : {mlagStatus:string}
negotiation status : {negotiation:string}
peer-link status : {peerlinkStatus:string}
local-int status : {localIntStatus:string}
system-id : {systemMAC:string}

MLAG Ports:
Disabled : {disabledPorts:number}
Configured : {configuredPorts:number}
Inactive : {InActivePorts:number}
Active-partial : {ActivePartialPorts:number}
Active-full : {ActiveFullPorts:number}

MLAG Detailed Status:
State : {mlagState:string}
Peer State : {mlagPeerState:string}
State changes : {mlagStateChanges:number}
Last state change time : {ChangeDays:number} days, {ChangeHours:string} ago
Hardware ready : {HardwareReady:string}
Failover : {Failover:string}
Failover Cause(s) : {FailoverCause:string}
Last failover change time : {FailOverDays:number} days, {FailOverTime:string} ago
Peer MAC address : {PeerMac:string}
Peer MAC routing supported : {PeerRoutingSupported:string}
Peer ports errdisabled : {PeerPortErrDisable:string}
Heartbeat timeouts since reboot : {HBTimeOuts:number}
UDP heartbeat alive : {HBAlive:string}
Agent should be running : {AgentRunning:string}
```;
export violationProcessing (CheckFail: Bool,violationReason: String,ReasonText: String) =
if CheckFail
then if violationReason == ""
then ReasonText
else violationReason+", "+ReasonText
else "";
//Process Show MLAG Detail output
export AristaMLAGDetail(device: Device) =

foreach command in device.outputs.commands
where command.commandText == "show mlag detail"
let mlagResponse = command.response
let deviceName = device.name
let parsed = parseConfigBlocks(OS.UNKNOWN, mlagResponse)
let Matches = blockMatches(parsed, mlagOutput)
foreach match in Matches
//Mlag Configuration Variables
let mlagDomain = match.data.MLAGDomain
let LocalInterface = match.data.LocalInterface
let peerAddress = match.data.PeerAddress
let peerLink = match.data.PeerLink
let hbPeerAddress= match.data.hbPeerAddress
let peerConfig = match.data.PeerConfig

//Mlag Status Variables
let mlagStatus = match.data.mlagStatus
let negStatus = match.data.negotiation
let peerLinkStatus = match.data.peerlinkStatus
let localIntStatus = match.data.localIntStatus
let systemMac = match.data.systemMAC

//Mlag Port Variables
let disabledPorts = match.data.disabledPorts
let configuredPorts = match.data.configuredPorts
let InActivePort = match.data.InActivePorts
let ActivePartialPorts = match.data.ActivePartialPorts
let ActiveFullPorts = match.data.ActiveFullPorts

//Mlag Detailed Status
let mlagState = match.data.mlagState
let peerState = match.data.mlagPeerState
let StateChanges = match.data.mlagStateChanges
let stateChangeDays = match.data.ChangeDays
let stateChangeHours = match.data.ChangeHours
let hardwareReady = match.data.HardwareReady
let failover = match.data.Failover
let failoverCause = match.data.FailoverCause
let failOverDays = match.data.FailOverDays
let failOverTime = match.data.FailOverTime
let peerMac = match.data.PeerMac
let peerMacRouting = match.data.PeerRoutingSupported
let peerPortErrDisable = match.data.PeerPortErrDisable
let HBTimeOuts = match.data.HBTimeOuts
let HBAlive = match.data.HBAlive
let AgentRunning = match.data.AgentRunning
let returnData = {
deviceName,
mlagDomain,
LocalInterface,
peerAddress,
peerLink,
hbPeerAddress,
peerConfig,
mlagStatus,
negStatus,
peerLinkStatus,
localIntStatus,
systemMac,
disabledPorts,
configuredPorts,
InActivePort,
ActivePartialPorts,
ActiveFullPorts,
mlagState,
peerState,
StateChanges,
stateChangeDays,
stateChangeHours,
hardwareReady,
failover,
failoverCause,
failOverDays,
failOverTime,
peerMac,
peerMacRouting,
peerPortErrDisable,
HBTimeOuts,
HBAlive,
AgentRunning}
select(returnData);

processMlag(mlagDetail,WarningReason,ViolationReason) =
foreach item in mlagDetail
let deviceName = item.deviceName
// Check MLAG Status if not Active then set violation to true with Reason Mlag state not Active
let CheckStatus = if item.mlagStatus != "Active" then true else false

// Check Peer Config is consistent
let ChkPeerConfig = if item.peerConfig != "consistent" then true else false

// Check the Negotiation Status and ensure it is connected.
let chkNeg = if item.negStatus != "Connected" then true else false

// Check the Peer Link Status to ensure it is Up.
let chkPeerLink = if item.peerLinkStatus != "Up" then true else false

// Check the Locacl Interface Status to ensure it is Up.
let chklocalLink = if item.localIntStatus != "Up" then true else false

// Check the Port Status and if there are any that are inactive or disabled then raise a warning.
let disabledPorts = item.disabledPorts
let InActivePorts = item.InActivePort
let ConfiguredPorts = item.configuredPorts
let partialPorts = item.ActivePartialPorts
let activePorts = item.ActiveFullPorts

let checkDisabled = if disabledPorts > 0 then true else false
let checkInActive = if InActivePorts > 0 then true else false
let checkPartial = if partialPorts > 0 then true else false
let warningPorts = disabledPorts+InActivePorts+partialPorts
let checkConfig = if ConfiguredPorts < warningPorts then true else false

//Check the State of the Peer and the local device and make sure we are not Active/Active
let localState = item.mlagState
let peerState = item.peerState
let CheckState = if localState == "primary" && peerState == "primary"
then "Both Primary"
else if localState == "secondary" && peerState == "secondary"
then "Both Secondary"
else ""

/* Check if there has been a failover in the last four hours I have set this to four hours because we poll every
four hours, if there has been we will generate a violation */

let failOverTime = duration(item.failOverTime)
let failOverDays = item.failOverDays
let failOver = item.failover
let failOverCause = item.failoverCause
let RecentFailover = if failOverDays == 0 && failOverTime <= hours(4)
then true
else false

// Check if the Peer Port is error disabled if it is then error.
let peerPort = item.peerLink
let peerErrDisable = if item.peerPortErrDisable != "False" then true else false

//Check the MLAG Agent is running
let AgentNotRunning = if item.AgentRunning != "True" then true else false
let results = {CheckStatus,ChkPeerConfig,chkNeg,chkPeerLink,chklocalLink,checkDisabled,checkInActive,checkPartial,checkConfig,CheckState,RecentFailover,peerErrDisable,AgentNotRunning}
select(results);

foreach device in network.devices
where device.platform.os == OS.ARISTA_EOS
let mlagDetail = AristaMLAGDetail(device)
let WarningReason = ""
let ViolationReason = ""

let violation = false
let ErrorStatus = ""

let results = processMlag(mlagDetail,WarningReason,ViolationReason)
foreach item in mlagDetail
let deviceName = item.deviceName
let localInt = item.LocalInterface
let localIntStatus = item.localIntStatus
let peerAddress = item.peerAddress
let peerLink = item.peerLink
let peerLinkStatus = item.peerLinkStatus
let localMac = item.systemMac
let peerMac = item.peerMac

foreach result in results
let ViolationReason = if result.CheckStatus
then violationProcessing(true,ViolationReason,"MLAG is not Active on the Sevice")
else if result.ChkPeerConfig
then violationProcessing(true,ViolationReason,"Peer Configuration is not consistent")
else if result.chkNeg
then violationProcessing(true,ViolationReason,"Negotiation status is not 'connected'")
else if result.chkPeerLink
then violationProcessing(true,ViolationReason,"Peer Link is not up")
else if result.chklocalLink
then violationProcessing(true,ViolationReason,"Local Interface is not up")
else if result.CheckState == "Both Primary"
then violationProcessing(true,ViolationReason,"Both Local and Peer device are primary")
else if result.CheckState == "Both Secondary"
then violationProcessing(true,ViolationReason,"Both Local and Peer device are Secondary")
else if result.peerErrDisable
then violationProcessing(true,ViolationReason,"Peer link is error disabled")
else if result.AgentNotRunning
then violationProcessing(true,ViolationReason,"MLAG Agent appears to not be running")
else ViolationReason
let WarningReason = if result.checkDisabled
then violationProcessing(true,WarningReason,"WARN There are disabled ports in the MLAG configuration")
else if result.checkInActive
then violationProcessing(true,WarningReason,"WARN There are in active ports in the MLAG configuration")
else if result.checkPartial
then violationProcessing(true,WarningReason,"WARN There are Active Partial ports in the MLAG configuration")
else if result.checkConfig
then violationProcessing(true,WarningReason,"WARN The Total number of ports in a state other than active full ports is the same or greater than the configured ports.")
else if result.RecentFailover
then violationProcessing(true,WarningReason,"WARN There has been a recent failover within the last 4 hours")
else WarningReason

let violation = if ViolationReason != "" then true else false
let State = if violation then withInfoStatus("ERROR",
InfoStatus.ERROR)

else if ViolationReason == "" && WarningReason != ""
then withInfoStatus("WARNING",InfoStatus.WARNING)
else withInfoStatus("OK",InfoStatus.OK)

let InformationText = if WarningReason != "" then violationProcessing(true,ViolationReason,WarningReason) else ViolationReason

select {
Name:deviceName,
MLAG_Result:State,
Local_Interface:localInt,
Local_Int_Status:localIntStatus,
Local_Mac_Address:localMac,
Peer_Link:peerLink,
Peer_Link_Status:peerLinkStatus,
Peer_Mac_Address:peerMac,
Information:InformationText,
violation:violation,
}