Skip to content

Instantly share code, notes, and snippets.

@bearice
Created December 25, 2019 05:57
Show Gist options
  • Save bearice/ccdf12cfd0905ccc0fb9f9e1e80c1c57 to your computer and use it in GitHub Desktop.
Save bearice/ccdf12cfd0905ccc0fb9f9e1e80c1c57 to your computer and use it in GitHub Desktop.

Revisions

  1. bearice created this gist Dec 25, 2019.
    12 changes: 12 additions & 0 deletions isis2dot.jq
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    def strip_isis_id: .|match("([-\\w]+).00").captures[0].string|gsub("-";"_") ;
    def to_dot: ["\(.id) -- {",(.n|join(" ")),"}"]|join("") ;

    ["strict graph {",
    "node [overlap=false]",
    (."isis-database-information"[]|."isis-database"[]|select(.level[0].data=="2")|."isis-database-entry"[]|{
    id:(."lsp-id"[0].data|strip_isis_id),
    n:[."isis-neighbor"[]|."is-neighbor-id"[0].data|strip_isis_id],
    p:[."isis-prefix"[]|."address-prefix"[0].data],
    rid:."isis-header"[0]."router-id"[0].data
    }|to_dot),
    "}"] | join("\n")