Skip to content

Commit ac2ff11

Browse files
authored
Merge pull request #86 from xxxserxxx/cli-report
Adds a code snippet for rending a nice table from the report in a CLI
2 parents 7e82e29 + 21d7047 commit ac2ff11

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

contrib/report_rendering/README.md

+38
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,41 @@ Courtesy of [@frillip](https://github.com/frillip/)
3131

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

34+
# CLI (bash)
35+
36+
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:
37+
38+
```bash
39+
sudo dsnet report | jq '.Peers' | jtbl
40+
```
41+
42+
The output looks like:
43+
```
44+
╒═════════╤═══════╤══════════╤══════════╤══════════╤══════════╤═════════╤════════╤══════════╤══════════╤══════════╤══════════╤══════════╤══════════╤══════════╕
45+
│ Owner │ IP6 │ Hostna │ Descri │ Online │ Dorman │ Added │ IP │ Extern │ Networ │ LastHa │ Receiv │ Transm │ Receiv │ Transm │
46+
│ │ │ me │ ption │ │ t │ │ │ alIP │ ks │ ndshak │ eBytes │ itByte │ eBytes │ itByte │
47+
│ │ │ │ │ │ │ │ │ │ │ eTime │ │ s │ SI │ sSI │
48+
╞═════════╪═══════╪══════════╪══════════╪══════════╪══════════╪═════════╪════════╪══════════╪══════════╪══════════╪══════════╪══════════╪══════════╪══════════╡
49+
│ xyz │ │ eaetl │ eaetl. │ True │ False │ 2222-0 │ 99.99. │ dddd:d │ [] │ 1111-1 │ 175995 │ 447007 │ 175.9 │ 32.7 M │
50+
│ │ │ │ fooo │ │ │ 2-22T1 │ 99.9 │ dd:ddd │ │ 1-11T1 │ 424 │ 28 │ MB │ B │
51+
│ │ │ │ │ │ │ 2:22:5 │ │ d:dddd │ │ 1:11:1 │ │ │ │ │
52+
│ │ │ │ │ │ │ 2.2274 │ │ :dddd: │ │ 1.1111 │ │ │ │ │
53+
│ │ │ │ │ │ │ 22222- │ │ dddd:d │ │ 11111- │ │ │ │ │
54+
│ │ │ │ │ │ │ 22:20 │ │ ddd:dd │ │ 11:11 │ │ │ │ │
55+
│ │ │ │ │ │ │ │ │ dd │ │ │ │ │ │ │
56+
├─────────┼───────┼──────────┼──────────┼──────────┼──────────┼─────────┼────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
57+
│ xyz │ │ ammedu │ ammedu │ True │ False │ 2222-0 │ 88.88. │ eeee:e │ [] │ 1111-1 │ 751670 │ 759741 │ 6.7 GB │ 727.7 │
58+
│ │ │ │ .mymy. │ │ │ 2-22T1 │ 88.8 │ eee:ee │ │ 1-11T1 │ 2852 │ 076 │ │ MB │
59+
│ │ │ │ com │ │ │ 2:22:4 │ │ ee:eee │ │ 1:11:1 │ │ │ │ │
60+
│ │ │ │ │ │ │ 2.2292 │ │ e::e │ │ 1.1111 │ │ │ │ │
61+
│ │ │ │ │ │ │ 22226- │ │ │ │ 11111- │ │ │ │ │
62+
│ │ │ │ │ │ │ 22:20 │ │ │ │ 11:11 │ │ │ │ │
63+
├─────────┼───────┼──────────┼──────────┼──────────┼──────────┼─────────┼────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────┤
64+
...
65+
```
66+
67+
To tighten up the table, use JQ to remove columns you're not interested in:
68+
69+
```
70+
sudo dsnet report | jq '.Peers | map(del(.Added,.Networks,.IP6,.Owner))' | jtbl
71+
```

0 commit comments

Comments
 (0)