Skip to content

Commit

Permalink
Merge pull request #86 from xxxserxxx/cli-report
Browse files Browse the repository at this point in the history
Adds a code snippet for rending a nice table from the report in a CLI
  • Loading branch information
naggie authored Aug 3, 2024
2 parents 7e82e29 + 21d7047 commit ac2ff11
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions contrib/report_rendering/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,41 @@ Courtesy of [@frillip](https://github.com/frillip/)

![dsnet report table](https://raw.githubusercontent.com/naggie/dsnet/master/etc/dsnet-report-js.png)

# CLI (bash)

On the command line, you can use [jtbl](https://github.com/kellyjonbrazil/jtbl) (and [jq](https://stedolan.github.io/jq/)) for a nice table rendering with this snippet:

```bash
sudo dsnet report | jq '.Peers' | jtbl
```

The output looks like:
```
╒═════════╤═══════╤══════════╤══════════╤══════════╤══════════╤═════════╤════════╤══════════╤══════════╤══════════╤══════════╤══════════╤══════════╤══════════╕
│ Owner │ IP6 │ Hostna │ Descri │ Online │ Dorman │ Added │ IP │ Extern │ Networ │ LastHa │ Receiv │ Transm │ Receiv │ Transm │
│ │ │ me │ ption │ │ t │ │ │ alIP │ ks │ ndshak │ eBytes │ itByte │ eBytes │ itByte │
│ │ │ │ │ │ │ │ │ │ │ eTime │ │ s │ SI │ sSI │
╞═════════╪═══════╪══════════╪══════════╪══════════╪══════════╪═════════╪════════╪══════════╪══════════╪══════════╪══════════╪══════════╪══════════╪══════════╡
│ xyz │ │ eaetl │ eaetl. │ True │ False │ 2222-0 │ 99.99. │ dddd:d │ [] │ 1111-1 │ 175995 │ 447007 │ 175.9 │ 32.7 M │
│ │ │ │ fooo │ │ │ 2-22T1 │ 99.9 │ dd:ddd │ │ 1-11T1 │ 424 │ 28 │ MB │ B │
│ │ │ │ │ │ │ 2:22:5 │ │ d:dddd │ │ 1:11:1 │ │ │ │ │
│ │ │ │ │ │ │ 2.2274 │ │ :dddd: │ │ 1.1111 │ │ │ │ │
│ │ │ │ │ │ │ 22222- │ │ dddd:d │ │ 11111- │ │ │ │ │
│ │ │ │ │ │ │ 22:20 │ │ ddd:dd │ │ 11:11 │ │ │ │ │
│ │ │ │ │ │ │ │ │ dd │ │ │ │ │ │ │
├─────────┼───────┼──────────┼──────────┼──────────┼──────────┼─────────┼────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
│ xyz │ │ ammedu │ ammedu │ True │ False │ 2222-0 │ 88.88. │ eeee:e │ [] │ 1111-1 │ 751670 │ 759741 │ 6.7 GB │ 727.7 │
│ │ │ │ .mymy. │ │ │ 2-22T1 │ 88.8 │ eee:ee │ │ 1-11T1 │ 2852 │ 076 │ │ MB │
│ │ │ │ com │ │ │ 2:22:4 │ │ ee:eee │ │ 1:11:1 │ │ │ │ │
│ │ │ │ │ │ │ 2.2292 │ │ e::e │ │ 1.1111 │ │ │ │ │
│ │ │ │ │ │ │ 22226- │ │ │ │ 11111- │ │ │ │ │
│ │ │ │ │ │ │ 22:20 │ │ │ │ 11:11 │ │ │ │ │
├─────────┼───────┼──────────┼──────────┼──────────┼──────────┼─────────┼────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
...
```

To tighten up the table, use JQ to remove columns you're not interested in:

```
sudo dsnet report | jq '.Peers | map(del(.Added,.Networks,.IP6,.Owner))' | jtbl
```

0 comments on commit ac2ff11

Please sign in to comment.