Script that queries cisco routers to pull the 'show dmvpn' output from the spoke hub routers. However we upgraded a hub router and the new IOS is showing now date/time info for "show dmvpn" command. Previous IOS versions only show 'never', and it throwing errors for newer IOS routers when using the script due to (\S+) only.
I tried to read up on Regular Expressions however couldn't make head/tails of how to join [3x] word/date/time.
Working:
if(pregmatch("/^\s+\d+\s+(\d+\.\d+\.\d+\.\d+)\s+(\d+\.\d+\.\d+\.\d+)\s+(\S+)\s+(\S+)\s+(\S+)/",$line,$hit))
#show dmvpn
# Ent Peer NBMA Addr Peer Tunnel Add State UpDn Tm Attrb
----- --------------- --------------- ----- -------- -----
1 192.168.1.1 42.10.10.10 UP **never** DN
1 192.168.1.1 42.10.10.10 UP **never** DN
1 192.168.1.1 42.10.10.10 UP **never** DN
Not Working: Regex is failing on newer IOS that actually shows date/time for the Up/Down tunnel timers:
#show dmvpn
# Ent Peer NBMA Addr Peer Tunnel Add State UpDn Tm Attrb
----- --------------- --------------- ----- -------- -----
1 192.168.1.1 42.10.10.10 UP **08:59:16** DN
1 192.168.1.1 42.10.10.10 UP **04:11:24** DN
1 192.168.1.1 42.10.10.10 UP **2d13h** DN
1 192.168.1.1 42.10.10.10 UP **3w0d** DN
1 192.168.1.1 42.10.10.10 UP **5d00h** DN
I got as far assuming I need to add (\d+:\d+:\d+) next to the 2nd to last (\S+) in the code but not sure how to join them, and included the 3w0d & 5d00h in there as well.
This seems like a easy regex fix, however is currently beyond my scope of coding. I tried to also search for an answer but everyone keeps using different terminology for 'regular expressions' & 'regex'