JC - JSON from CLI
how to build json from cli
we all like json, do we ? https://kellyjonbrazil.github.io/jc/docs/parsers/ping
add package
doas pkg_add jc
try ping
openbsd-box # ping -c 3 1.1.1.1 |jc --ping -p 2>/dev/null
{
"destination_ip": "1.1.1.1",
"data_bytes": 56,
"pattern": null,
"destination": "1.1.1.1",
"packets_transmitted": 3,
"packets_received": 3,
"packet_loss_percent": 0.0,
"duplicates": 0,
"round_trip_ms_min": 9.219,
"round_trip_ms_avg": 9.826,
"round_trip_ms_max": 10.158,
"round_trip_ms_stddev": 0.43,
"responses": [
{
"type": "reply",
"bytes": 64,
"response_ip": "1.1.1.1",
"icmp_seq": 0,
"ttl": 59,
"time_ms": 10.158,
"duplicate": false
},
{
"type": "reply",
"bytes": 64,
"response_ip": "1.1.1.1",
"icmp_seq": 1,
"ttl": 59,
"time_ms": 9.219,
"duplicate": false
},
{
"type": "reply",
"bytes": 64,
"response_ip": "1.1.1.1",
"icmp_seq": 2,
"ttl": 59,
"time_ms": 10.101,
"duplicate": false
}
]
}
Compatible platforms: linux, darwin, freebsd -> had to redirect the stderr to /dev/null because OpenBSD is not (yet) supported officially…