Page 1 of 1

Get "root bridge ID" from devices

Posted: Mon Jul 12, 2021 7:47 pm
by lucapsg
I need to monitor the RSTP status of some devices and to do that I would need to know the current "root bridge id" of each.
I saw that the command
/interface bridge monitor bridge once 
includes this information but how do I just extract the single line and store it in a variable?
Thank you.

Re: Get "root bridge ID" from devices

Posted: Mon Jul 12, 2021 7:52 pm
by rextended
nominated "bridge1"
:global bridge1id ([/interface bridge monitor bridge1 once as-value ]->"root-bridge-id")
:put $bridge1id

function
:global getid do={:return ([/interface bridge monitor $1 once as-value ]->"root-bridge-id")}
:global bridge1id [$getid bridge1]
:put $bridge1id

all
/interface bridge
    :foreach idx in=[find] do={
        :put ([monitor $idx once as-value ]->"root-bridge-id")
    }

Re: Get "root bridge ID" from devices

Posted: Mon Jul 12, 2021 8:08 pm
by lucapsg
Wow, rapid and exhaustive!
I did not know this syntax.
Thank you / Grazie.

Re: Get "root bridge ID" from devices

Posted: Mon Jul 12, 2021 8:10 pm
by rextended
IT: ho modificato il post precedente per fare meglio quello che hai chiesto ho dimenticato "and store it in a variable"

EN: I edited the previous post to do better what you asked for, I miss "and store it in a variable"