linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas D Steeves <nsteeves@gmail.com>
To: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>
Cc: "Richard W.M. Jones" <rjones@redhat.com>,
	Btrfs BTRFS <linux-btrfs@vger.kernel.org>,
	ptoscano@redhat.com
Subject: Re: RFE: 'btrfs' tools machine readable output
Date: Fri, 27 May 2016 15:47:55 -0400	[thread overview]
Message-ID: <CAD=QJKjx3QstqTB8kFLO7uYFuCNf7S++TTBkMkmnAPfp9iw1Uw@mail.gmail.com> (raw)
In-Reply-To: <1c0d1dbc-325b-829a-762c-67288bb957a3@gmail.com>

On 16 May 2016 at 08:39, Austin S. Hemmelgarn <ahferroin7@gmail.com> wrote:
> On 2016-05-16 08:14, Richard W.M. Jones wrote:
>>
>> It would be really helpful if the btrfs tools had a machine-readable
>> output.
>> With machine-readable output, there'd be a flag which would
>> change the output.  eg:
>> $ btrfs --json filesystem show
>> {
>>   "devices": {
>>      "Label": "ROOT",
>>      "uuid": "af471cfc-421a-4d51-8811-ce969f76828a",
>>      /// etc
>>   }
>> }
> I would love to see something like this myself, as it would make integration
> with monitoring tools so much easier.  I'd vote for YAML as the output format
> though, as it's easily human readable as well as machine parseable while
> still being space efficient.
> ---
> - filesystems
>   - label: 'ROOT'
>     uuid: af471cfc-421a-4d51-8811-ce969f76828a
>     devices: 1
>       - devid: 1
>         size: 767.97 MB
>         used 92.00 MB
>         path: /dev/sda2
>     used: 5.29 MB
> ...

Rather than adding language-specific output/extensions to btrfs-progs,
what does everyone think of an interface which allows arbitrary
ordering similar to the date command, with arbitrary delimiter
support?

eg: date +%a\ %d\ \%B\ %H:%m

with something like: %D (device), %L (label), %V (volume), %v
(subvolume), %U (volume UUID), %u (subvol UUID), et al.

'avoids formatting the output to any particular convention, and the
order of what is queried can be in any order...but I think the [unit
to operate on] [named unit] bit would necessarily need to come first.
We already have that in btrfs [sub/fi/dev] [name] :-)

Or should it be a separate command...  Something like "btrfs-machine
[unit to operate on] [named unit] [action eg: print] [cryptic line
with user's choice of delimiter and formatting]".  And then there
might also be the option to "btrfs-machine [unit to operate on] [named
unit] return [scrub status, balance status, etc.]" which returns a
single integer value along the lines of idle|in
progress|success|failure.  And at some point in the future
btrfs-machine [unit to operate on] [named unit] progress [operation]
which functions like "fsck -C [fd]".

Now that, I imagine, would be something libvirt users would like,
whether for web interface, GUI, or wrapper script for for a slick NAS
web interfaces.

For now, maybe start with a proof of concept with only the "print"
action implemented?  And eventually merge this into the main btrfs
command something like this: "btrfs -m unit name action args" or
"btrfs --machine unit name action args"

On 16 May 2016 at 08:21, Martin Steigerwald <martin@lichtvoll.de> wrote:
> How about a libbtrfs so that other tools can benefit from btrfs tools
> functionality?
Does much does /usr/lib/x86_64-linux-gnu/libbtrfs.so expose?

What is the path of minimum duplication of work, and minimum long-term
maintenance?  If my assumptions are correct, this is a 2000-level
programming course textbook challenge on writing a program using a
library to query some values...and that might be something I could
manage :-)

Cheers,
Nicholas

  reply	other threads:[~2016-05-27 19:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-16 12:14 RFE: 'btrfs' tools machine readable output Richard W.M. Jones
2016-05-16 12:21 ` Martin Steigerwald
2016-05-16 12:39   ` Richard W.M. Jones
2016-05-16 12:46   ` Pino Toscano
2016-05-16 12:39 ` Austin S. Hemmelgarn
2016-05-27 19:47   ` Nicholas D Steeves [this message]
2016-05-31 12:15     ` Austin S. Hemmelgarn
2016-05-17  9:33 ` David Sterba
2016-05-17 11:14   ` Austin S. Hemmelgarn
2016-05-17 12:23     ` David Sterba
2016-05-17 13:05       ` Austin S. Hemmelgarn
2016-05-17 13:32         ` Richard W.M. Jones
2016-05-17 15:04           ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAD=QJKjx3QstqTB8kFLO7uYFuCNf7S++TTBkMkmnAPfp9iw1Uw@mail.gmail.com' \
    --to=nsteeves@gmail.com \
    --cc=ahferroin7@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=ptoscano@redhat.com \
    --cc=rjones@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).