Last active
September 10, 2020 13:06
-
-
Save emilgaripov/816ecef9bda3d32ee73315173f33e763 to your computer and use it in GitHub Desktop.
traceroute.textfsm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
traceroute = """ | |
r2#traceroute 90.0.0.9 source 33.0.0.2 | |
traceroute 90.0.0.9 source 33.0.0.2 | |
Type escape sequence to abort. | |
Tracing the route to 90.0.0.9 | |
VRF info: (vrf in name/id, vrf out name/id) | |
1 10.0.12.1 1 msec 0 msec 0 msec | |
2 15.0.0.5 0 msec 5 msec 4 msec | |
3 57.0.0.7 4 msec 1 msec 4 msec | |
4 79.0.0.9 4 msec * 1 msec | |
""" | |
with open("traceroute.template") as template: | |
fsm = textfsm.TextFSM(template) | |
result = fsm.ParseText(traceroute) | |
print(fsm.header) | |
print(result) | |
""" | |
Example: | |
['ID', 'Hop'] | |
[['1', '10.0.12.1'], ['2', '15.0.0.5'], ['3', '57.0.0.7'], ['4', '79.0.0.9']] | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment