Code: Select all
/routing bgp advertisements get [find peer="XXX"] value-name=prefix
/routing bgp advertisements get [find peer="XXX"] value-name=prefix
:put [routing bgp advertisements get number=*0]
:foreach advr in=[/routing bgp advertisements print peer="RR" as-value] do={:put ($advr->"prefix")}
:local pname
:local advrn
:local advrdata
:local advrprefix
:local advrid
:local advrpath
:local aa
:local taa
## find active peers
:foreach peerid in=[/routing bgp peer find where established] do={
#:log info "$peerid"
## get peer name
:set pname [/routing bgp peer get value-name=name number=$peerid]
## get how many prefix count it have. at ver 5 is an error thats gives always -1
:set advrn [/routing bgp advertisements print $peerid count-only as-value]
# :log info "checking $pname with $advrn advertisment"
## save advertisements to file
# /routing bgp advertisements print peer=$peerid terse file=$pname
# get advertisements to var as array
:set advrdata [/routing bgp advertisements print $pname as-value]
## parse data to vars
:foreach advr in=$advrdata do={
:set advrprefix ($advr->"prefix")
:set advrid ($advr->".id")
:set advrpath ($advr->"as-path")
:set aa ($aa +1)
:set taa ($taa +1)
#:log info "$advr"
:log info "$aa of peer $pname $taa total with ID $advrid Prefix $advrprefix path $advrpath "
}
#:log info "Peer $pname result find $aa entrys"
# reset counter for peer
:set aa 0
}