JSON input / output for CLI utilities
Andrew Walker
awalker at ixsystems.com
Sat May 29 10:23:10 UTC 2021
On Sat, May 29, 2021 at 5:55 AM Martin Schwenke <martin at meltin.net> wrote:
> Hi Andrew,
>
> On Thu, 27 May 2021 17:42:20 -0400, Andrew Walker via samba-technical
> <samba-technical at lists.samba.org> wrote:
>
> > I know we've added JSON output to a few of the CLI utils. Over the past
> > year or so I've added this to various utils in FreeNAS (using
> libjansson).
> > Is there an overall strategy for this? I'd be happy to upstream what I
> have.
>
> Sounds good!
>
> > Also is there an effort to add support for JSON input to them?
>
> Your effort appears to be it! Thanks for that! :-)
>
> One wishlist item to think about... and my example is for CTDB... :-)
>
> If adding JSON output and, perhaps, input it would cool to have the
> command-line tools be able to run in a mode where they stay connected
> to the relevant Unix domain socket. The most useful example would
> allow "ctdb statistics" to be repeatedly run within the one session, so
> a reporting tool can periodically collect the output without the need
> to reconnect.
>
> This could go hand-in-hand with addition of an interactive mode on
> tools that don't have one (e.g. "ctdb").
>
> If this is an interesting idea then I'm happy to try to work on that
> with you in whatever time I have available...
>
> peace & happiness,
> martin
>
Yeah, I have some added for most of the ctdb commands.
truenas# ctdb -j status | jq
{
"nodemap": {
"node_count": 2,
"deleted_node_count": 1,
"nodes": [
{
"pnn": 0,
"address": "192.168.122.176",
"flags_str": "OK",
"flags_raw": 0,
"partially_online": false,
"this_node": true
}
]
},
"generation": 1598490685,
"size": 1,
"vnnmap": [
{
"hash": 0,
"lmaster": 0
}
],
"recovery_mode_raw": 0,
"recovery_mode_str": "NORMAL"
}
This one will take a little more time since in the patchset I duplicated
many functions from /lib/audit_logging to separate library
"/lib/json_minimal" to have some minimal set of JSON-related functions to
make bolting-on JSON support somewhat simpler.
More information about the samba-technical
mailing list