networktocode / ntc-templates

TextFSM templates for parsing show commands of network devices
https://ntc-templates.readthedocs.io/
Other
1.12k stars 730 forks source link

Aruba AOSCX show system output fails when the uptime contains string "under a minute" #1837

Closed ericspacket closed 2 months ago

ericspacket commented 2 months ago
ISSUE TYPE
TEMPLATE USING
Value Required HOSTNAME (\S+)
Value CONTACT (\S+)
Value LOCATION (\S+)
Value VENDOR (\S+)
Value PRODUCT (.+)
Value SERIAL (\S+)
Value BASE_MAC (\S+)
Value VERSION (\S+)
Value TIME_ZONE (\S+)
Value UPTIME_WEEKS (\d+)
Value UPTIME_DAYS (\d+)
Value UPTIME_HOURS (\d+)
Value UPTIME_MINUTES (\d+)

Start
  ^Hostname\s+:\s+${HOSTNAME}
  ^System Description\s+:\s*\S+
  ^System Contact\s+:\s+${CONTACT}      
  ^System Contact\s+:
  ^System Location\s+:\s+${LOCATION}
  ^System Location\s+:
  ^Vendor\s+:\s+${VENDOR}
  ^Product Name\s+:\s+${PRODUCT}
  ^Chassis Serial Nbr\s+:\s+${SERIAL}
  ^Base MAC Address\s+:\s+${BASE_MAC}   
  ^ArubaOS-CX Version\s+:\s+${VERSION}
  ^Time Zone\s+:\s+${TIME_ZONE}
  ^Up Time\s+:\s+${UPTIME_WEEKS}\sweek -> Continue
  ^.*${UPTIME_DAYS}\s+(day|days) -> Continue
  ^.*${UPTIME_HOURS}\s+(hour|hours) -> Continue
  ^.*${UPTIME_MINUTES}\s+(minute|minutes) -> Record
  ^CPU
  ^Memory
  ^-+$$
  ^\*+$$
  ^\s*$$
  ^. -> Error "LINE NOT FOUND"
SAMPLE COMMAND OUTPUT
Hostname           : 6300
System Description : FL.10.10.1070
System Contact     : 
System Location    : 

Vendor             : Aruba
Product Name       : JL664A 6300M 24G 4SFP56 Swch
Chassis Serial Nbr : xxxxxxxxxx
Base MAC Address   : 001122-334455
ArubaOS-CX Version : FL.10.10.1070

Time Zone          : America/Edmonton

Up Time            : 2 weeks, 22 hours under a minute
CPU Util (%)       : 8
Memory Usage (%)   : 25
SUMMARY

On Aruba AOSCX the show system command has the string 'under a minute' as part of the Up Time output which breaks the current template. It is just chance someone will run into this.

STEPS TO REPRODUCE
EXPECTED RESULTS

The output to be parsed successfully

ACTUAL RESULTS
"Error: \"LINE NOT FOUND\". Rule Line: 37. Input Line: Up Time            : 2 weeks, 22 hours under a minute."
jmcgill298 commented 2 months ago

@ericspacket can you put in a PR to fix this?

mjbear commented 2 months ago

@ericspacket Are you going to work up a PR on this?

It's been two weeks so if I don't see a response from you on this thread in a few hours I'll probably work up a fix.

mjbear commented 2 months ago

@ericspacket I added a rule so that once under a minute is hit the Record action is triggered (similar to when a normal minute value was present).

^.*under\s+a\s+minute -> Record

I submitted PR #1858 Thank you!

Edit: Actually there is a larger uptime parsing issue that I'm working to identify and fix. :confounded:

mjbear commented 2 months ago

Update: Essentially if the time value was greater than a single digit the first digit was being lopped off (probably regex greediness). It appears this issue has been there since the template was created, but was just not caught. :man_shrugging:

I compressed things down to a single long regex for the time line. Not only does it match the under a minute, but it also has the correct digits captured now.

mjbear commented 2 months ago

I updated PR #1858 with the fix for the incorrect time digit capturing in addition to the under a minute text. https://github.com/networktocode/ntc-templates/pull/1858/files

@ericspacket @afly007