kellyjonbrazil / jc

CLI tool and python library that converts the output of popular command-line tools, file-types, and common strings to JSON, YAML, or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.
MIT License
7.92k stars 210 forks source link

New Streaming-parser proposal: traceroute-s #576

Open Mabuchin opened 4 months ago

Mabuchin commented 4 months ago

Overview

Currently, traceroute does not support streaming IO parsing. Given that traceroute can sometimes take a long time to complete, it would be beneficial in many cases to receive data via a stream as it becomes available, rather than waiting for the entire command to finish.

Proposal

I propose implementing a new feature, traceroute-s, which would return data in a streaming format. This would allow for real-time processing of traceroute data as it's generated.

Response Format

The streaming parser would return data in the following JSON format:

{
  "type":                       "string",   # 'header', 'hop', 'error', 
  "destination_ip":             "string",
  "destination_name":           "string",
  "hops": [
    {
      "hop":                "integer",
      "probes": [
        {
          "annotation":     "string",
          "asn":            "integer",
          "ip":             "string",
          "name":           "string",
          "rtt":            "float"
        }
      ]
    }
  ],
  # below object only exists if using -qq or ignore_exceptions=True
  "_jc_meta": {
    "success":                  "boolean",  # false if error parsing
    "error":                    "string",   # exists if "success" is false
    "line":                     "string"    # exists if "success" is false
  }
}

Implementation Status

I have already implemented this feature in a fork of traceroute-s. If this proposal is accepted, I'm ready to submit it as a Pull Request.

kellyjonbrazil commented 4 months ago

Hi there - thank you for the parser suggestion and I look forward to the PR!

kellyjonbrazil commented 2 months ago

@Mabuchin did you want to submit a PR for this?