Counting prefered routes for a protocol with bird2

Alarig Le Lay alarig at swordarmor.fr
Tue Nov 27 15:32:36 CET 2018


Hi,

With bird1, I can know how much routes are used for each protocol just
by parsing birdc:
[alarig at nominoe ~]$ birdc show protocols all bgp_breizhix | grep 'Routes:'
  Routes:         75 imported, 0 filtered, 4 exported, 73 preferred

With bird2, I don’t see this information:
[alarig at budic ~]$ birdc -r show protocols all bgp_breizhix_ipv4
BIRD 2.0.2 ready.
Access restricted
Name       Proto      Table      State  Since         Info
bgp_breizhix_ipv4 BGP        ---        up     2018-11-21    Established
  Description:    BreizhIX
  BGP state:          Established
    Neighbor address: 185.1.89.1
    Neighbor AS:      206165
    Neighbor ID:      185.1.89.1
    Local capabilities
      Multiprotocol
        AF announced: ipv4
      Route refresh
      Graceful restart
      4-octet AS numbers
      Enhanced refresh
    Neighbor capabilities
      Multiprotocol
        AF announced: ipv4
      Route refresh
      Graceful restart
      4-octet AS numbers
      Enhanced refresh
    Session:          external AS4
    Source address:   185.1.89.13
    Hold timer:       216.225/240
    Keepalive timer:  12.810/80
  Channel ipv4
    State:          UP
    Table:          master4
    Preference:     100
    Input filter:   bgp_filter_breizhix_in_ipv4
    Output filter:  (unnamed)
    Receive limit:  800000
      Action:       block
    Export limit:   4
      Action:       block
    Routes:         75 imported, 0 filtered, 4 exported
    Route change stats:     received   rejected   filtered    ignored   accepted
      Import updates:             90          0          0          0         90
      Import withdraws:           15          0        ---          0         15
      Export updates:        5738200         88    5738108        ---          4
      Export withdraws:       155358        ---        ---        ---          0
    BGP Next hop:   185.1.89.13

The only way I found is by using 'show route count primary', but it
takes so many time:

[alarig at nominoe ~]$ time birdc show protocols all bgp_breizhix | grep 'Routes:' | sed -Ee '/preferred/{ s/^.* ([0-9]+) 'preferred'.*$/\1/; p;}' -e d
73

real    0m0.003s
user    0m0.000s
sys     0m0.006s

[alarig at budic ~]$ time birdc -r show route count primary table master4 protocol bgp_breizhix_ipv4 | awk '/routes/ { print $1 }'
73

real    0m0.612s
user    0m0.000s
sys     0m0.003s

Is there a faster manner to do this?

My goal is to adapt
https://git.grifon.fr/alarig/munin-bird/src/branch/master/bird_ to
bird2.

Thanks,
-- 
Alarig


More information about the Bird-users mailing list