TextFSM-Based Structured Processing

TextFSM-Based Structured Processing

Introduction

Modern network devices generate large amounts of CLI-based output that is designed for human readability rather than automation. While this format works well for engineers troubleshooting devices manually, it presents challenges when integrating with monitoring systems, inventory tools, and automation platforms.

TextFSM and NTC Templates provide a structured way to solve this problem. TextFSM is a parsing engine driven by templates that converts unstructured CLI output into structured, machine-readable data such as tables, dictionaries, CSV, or JSON. NTC Templates is a collection of reusable parsing templates, that enables consistent data extraction across different vendors and device types.

Within opConfig, TextFSM-based structured processing allows command outputs to be parsed automatically and then used for:

  • Table generation

  • Inventory updates

  • Alert creation

  • Event correlation

  • Reporting and automation workflows

This document explains how TextFSM works, where templates are located, and how to test and integrate structured parsing within opConfig.


opConfig TextFSM Plugins

We have created four opConfig plugins to allow the use of TextFSM in opConfig Command Sets.

TextFsm

·       Uses TextFSM to parse raw CLI output using NTC Templates

·       Produces structured JSON data

TextFsmTable

·       Generates structured table output using the custom_table_configuration Command Set parameter

TextFsmInventory

·       Updates node inventory data

AlertTextFsmMTU

·       Evaluates MTU values

·       Creates alerts in opEvents when thresholds are triggered

 

opConfig Setup for TextFSM

Command Sets can be configured to perform TextFSM-based structured processing within opConfig.

Each Command Set supports the use of plugins, which allow the raw command output to be parsed, transformed, and processed according to specific requirements. These plugins can:

  • Convert unstructured CLI output into structured data using TextFSM

  • Generate custom tables

  • Update inventory attributes

  • Create alerts or events

  • Perform additional post-processing logic

For detailed setup instructions and an example, refer to:

How to Setup a Command Set for TextFSM-Based Structured Processing


Template Location

All standard templates are available in the contrib directory:

/usr/local/omk/contrib/ntc_templates/

Manual TextFSM CLI Testing

We can use the gotextfsm-impl binary to verify the structured output generated from raw command output.

For example, to generate structured output from the show interfaces command, run:

/usr/local/omk/bin/gotextfsm-impl \ -command 'show interfaces' \ -vendor cisco \ -os 'ios' \ -templatedir '/usr/local/omk/contrib/ntc_templates' \ -inputfile '/tmp/JfnXHO93xI'

Where:

  • -command → The CLI command being parsed

  • -vendor → Device vendor

  • -os → Device operating system

  • -templatedir → Path to TextFSM templates

  • -inputfile → File containing the raw CLI output

The input file should contain the actual command output from the device (for example, the output of show interfaces from a Cisco router).

This allows you to validate template parsing before integrating it into opConfig.