I'm not sure if the following is possible, I certainly have failed to make it work with my limited scripting knowledge, and was hoping someone can point me in the right direction or tell me it's not feasible.
I'd like to track MAC-Address to port's for reference, and to avoid manual lookup when needed. (I support a lot of clients that have folks that will re-cable without approval / documenting changes).
For one client, the relevant info is in /interface bridge host print, but I can not figure out how to extract the elements (mac-address, on-interface) for further processing or storage. I'm aware that some interfaces will have multiple mac-addresses, etc.
Any assistance, or indication I'm wasting my time, would be appreciated.
This would require you to create a script that regulary walks trought the bridge host table, and store new interface recod for each MAC.
First create array where you will store interface records for each MAC address.
:global arr {mac="interfaces"};
Add script which will look for new mac-interface pairs, this part should be added in scheduler for regular execution
:global arr;
foreach host in=[interface bridge host find] do={
:local mac [/interface bridge host get $host mac-address]
:local iface [/interface bridge host get $host on-interface]
if (($arr->"$mac")~"$iface;") do={:put "Interface already on list";} else={
:put "New inteface for mac $mac"
:set ($arr->"$mac") (($arr->"$mac")."$iface;")
}
}
print out results, or store them on file
foreach k,v in=$arr do={
:put ("$k=$v")
}
https://wiki.mikrotik.com/wiki/Manual:System/Scheduler
https://wiki.mikrotik.com/wiki/Manual:Scripting
To exclude local mac records, you can use:
/interface bridge host find where !local