Count split routes

Hi. Has anyone found a way to count split routes (ecmp routes)?
Routes that are either statically defined or imported via OSPF.

This is handy when OSPF creates split routes in more complex networks under certain conditions.

So, in essense, alert on split route.
Anybody?

loop through routes and count +1 if gateway value is an array with more than one element

Thank you.

Final result.

:local dst
:local splitcount 0
:foreach dst in=[/ip route find] do={
    :set dst [/ip route get value-name=gateway number=$dst]
    :local elementcount 0
    :foreach i in=$dst do={
        set elementcount ($elementcount + 1)
        }
    
    :if ( $elementcount > 1) do={
        #:put "$dst";
        set splitcount ($splitcount + 1)
        }
}
:put "splitcount $splitcount"

Some conflicts here…

:local dst

:foreach dst in=[/ip route find] do={
:set dst [/ip route get value-name=gateway number=$dst]

used same name from local variable and variable obtained from foreach cycle


Probably the script must be like:

{
    :local splitcount 0
    /ip route
    :foreach item in=[find] do={
        :local gat [get $item gateway]
        :if ([:len $gat] > 1) do={
            :set splitcount ($splitcount + 1)
        }
    }
    :put "splitcount $splitcount"
}