ntc-templates icon indicating copy to clipboard operation
ntc-templates copied to clipboard

truncated time in cisco_nxos_show_ip_bgp_neighbors.textfsm

Open ajw1980 opened this issue 2 years ago • 1 comments

For values less than 1 day this regex is incorrect for cisco_nxos_show_ip_bgp_neighbors.textfsm:

Value UPTIME (\w+)
Value LAST_RESET (\w+)
Value LAST_PEER_RESET (\w+)

It is HH:MM:SS for values less than 1 day: BGP state = Established, up for 20:03:51

I think this change is sufficient:

Value UPTIME ([\w:]+)
Value LAST_RESET ([\w:]+)
Value LAST_PEER_RESET ([\w:]+)

ajw1980 avatar Aug 18 '22 20:08 ajw1980

@ajw1980 @itdependsnetworks

I tinkered around with it starting out with \S+ first only to find that when a peer is in the idle BGP state then the template picks up an extra comma. Easily remedied by modifying the State Rule to make the comma optional, but there's a problem with that.

Edit: Had I tested before initially commenting I would have caught the error in my logic. The comma still gets captured as part of the UPTIME because it is optional at the end of that line. I'm going to vote [\w:]+ is going to be the pattern for UPTIME.

Capture groups for LAST_RESET and LAST_PEER_RESET could be \S+ because the text surrounding them (trailing comma) is not optional.

  • Are there any complaints to using two different regexes?
    • UPTIME uses ajw's suggested pattern [\w:]+
    • LAST_RESET and LAST_PEER_RESET use another

mjbear avatar Jan 07 '24 17:01 mjbear

no complaints, what are next steps?

ryanmerolle avatar Jun 19 '24 03:06 ryanmerolle

@ryanmerolle I'd say it just comes down to somebody (I'll volunteer) pulling a PR together.

I had been chasing some of these and when there was no response I moved on to other priorities. :shrug: That's life. Thank you

mjbear avatar Jun 20 '24 16:06 mjbear

@ryanmerolle @jvanderaa I have a PR ... it's #1719 to allow capturing BGP uptimes less than a day (the part that wasn't working) as well as beyond a full day

mjbear avatar Jun 21 '24 17:06 mjbear

@jvanderaa can we please close this issue with PR is closed.

ryanmerolle avatar Jun 22 '24 01:06 ryanmerolle