Hello,
I'm currently working on a web app which needs to receive structured data ("show ip bgp neighbours" etc.) from my VyOS routers and parse it into a table.
I'm currently using a TextFSM template to parse data over SSH, which works fine, but it is a bit slow and doesn't work well for a web app (where there can be concurrent users).
The API would work a lot better, but it doesn't structure the output of all the show commands.
Adding the template shouldn't be difficult, and I'm happy to do so myself, but I'm not entirely sure which parts of the codebase need to be modified to return structured data.
It might need to be modified slightly:
Value Filldown VRF (\S+?) Value Filldown ROUTER_ID (\S+) Value Filldown LOCAL_AS (\d+) Value BGP_NEIGH ((([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))|((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])) Value NEIGH_AS (\d+) Value MSG_RCVD (\d+) Value MSG_SENT (\d+) Value UP_DOWN (\S+?) Value STATE_PFXRCD (\S+?\s+\S+?|\S+?) Value STATE_PFXSNT (\S+?\s+\S+?|\S+?) Value DESC (\S+) Start ^IPv4\s+Unicast\s+Summary\s+\(VRF\s+${VRF}\):$$ ^BGP\s+router\s+identifier\s+${ROUTER_ID},\s+[Ll]ocal\s+[Aa][Ss]\s+number\s+${LOCAL_AS}\s+vrf-id\s+\d+$$ ^BGP\s+table\s+version\s+\d+$$ ^RIB\s+entries\s+\d+,\s+using\s+\d+\s+[M/K]iB\s+of\s+memory$$ ^Peers\s+\d+,\s+using\s+\d+\s+KiB\s+of\s+memory$$ ^Peer\s+groups\s+\d+,\s+using\s+\d+\s+bytes\s+of\s+memory$$ ^Neighbor\s+V\s+AS\s+MsgRcvd\s+MsgSent\s+TblVer\s+InQ\s+OutQ\s+Up/Down\s+State/PfxRcd\s+PfxSnt\s+Desc$$ ^${BGP_NEIGH}\s+\S+\s+${NEIGH_AS}\s+${MSG_RCVD}\s+${MSG_SENT}(\s+\d+?){3}\s+${UP_DOWN}\s+${STATE_PFXRCD}\s\s+${STATE_PFXSNT}\s+${DESC}\s*$$ -> Record ^Total\s+number\s+of\s+neighbors\s+\d+$$ ^\s*$$ ^. -> Error EOF
Thanks,
Usman