Simplicity is the ultimate sophistication

Font Size




Looking ahead when using TextFSM to extract information from text

TextFSM is a very useful Python module that can be used to extract information from a text and store the information in a tabular structure (table/spreadsheet etc)

The idea behind the TextFM is to create a template for each specific text you need to process (output of command) and to use that template to extract the information. You will define the column using the keyword “Value” in your template and then you will create rules to process each line.

There is a particular situation like below when you want to save all data collected from the lines between two similar lines (the lines containing the word “interface” in our case). I could not figure out other way to look ahead other than the below. The trick is suggested by the author of the module in his example of using lists. In our case we do not want lists but we just want to look ahead ….

interface Loopback1
interface Eth1/1
  speed 100
  duplex full
interface Eth1/2
  duplex full
interface Eth1/3
  speed 100

Your template could look like below

Value Required Interface (\S+)
Value Speed (\d+)
Value Duplex (full)

# the below line will not save the record at
# the first hit because $Interface=''
# the second time the rule is hit (when we reach
# the next interface) it will save the already collected record) ^interface ->Continue.Record ^\s+speed ${Speed} ^\s+duplex ${Duplex} ^\interface ${Interface}

so you are saving the record only after looking forward for each interface line, processing the config lines and save when you hit the next "interface” line.

This is an important trick because that is the only way to look ahead... as far as I can tell (might be wrong I am just started using this)

    More Wireshark/Pcap Toos

    All the credits for this great content go to caesar0301 @ https://github.com/caesar0301/awesome-pcaptools 
    I just saved the below in case his page disappears… this will complement my own list : http://www.1001qa.net/index.php/tools/109-wireshark-tools


    This project does not contain any source code or files. I just want to make a list of tools to process pcap files in research of network traffic. For more awesome lists, see https://github.com/sindresorhus/awesome

    License: Apache License v2.

    TinyCore for GNS3 or VMWare

    I needed to install a small footprint linux appliance for GNS3 and VMware (ESXi 6.5). I was not really happy with the VPC option in GNS3. Here are the steps I took to install this.
    TinyCore is designed to wipe out at the next reboot any changes you have made to the OS. The idea is to have a system that will never crash. I guess it is designed for appliances that do not need to store any persistent data. This is not exactly ideal for a network appliance. So then why TinyCore? The answer is simple: it has a small foot print, works fine with 64M of RAM and no HDD if you want that or with a small virtual HDD .

    Useful links

    http://tinycorelinux.net/downloads.html   -base system and extensions download page
    http://distro.ibiblio.org/tinycorelinux/install.html  -installation instructions
    http://tinycorelinux.net/corebook.pdf  -good all in one doc
    http://wiki.tinycorelinux.net/wiki:persistence_for_dummies –persistence explained

    An article to review


    I am saving this here. I hope I will find an hour to look closer to the article and to his site.

    Cograts to Jedadiah Casey @Wax_Trax