linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sidong Yang <realwakka@gmail.com>
To: dsterba@suse.cz, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2] btrfs-progs: device stats: add json output format
Date: Sun, 1 Nov 2020 03:26:22 +0000	[thread overview]
Message-ID: <20201101032622.GA1015@realwakka> (raw)
In-Reply-To: <20201030175525.GZ6756@twin.jikos.cz>

On Fri, Oct 30, 2020 at 06:55:25PM +0100, David Sterba wrote:
> On Sun, Oct 04, 2020 at 11:25:57AM +0000, Sidong Yang wrote:
> > Add supports for json formatting, this patch changes hard coded printing
> > code to formatted print with output formatter. Json output would be
> > useful for other programs that parse output of the command. but it
> > changes the text format.
> > 
> > Example text format:
> > 
> > device:                 /dev/vdb
> > write_io_errs:          0
> > read_io_errs:           0
> > flush_io_errs:          0
> > corruption_errs:        0
> > generation_errs:        0
> > 
> > Example json format:
> > 
> > {
> >   "__header": {
> >     "version": "1"
> >   },
> >   "device-stats": {
> >     "/dev/vdb": {
> >       "device": "/dev/vdb",
> >       "write_io_errs": "0",
> >       "read_io_errs": "0",
> >       "flush_io_errs": "0",
> >       "corruption_errs": "0",
> >       "generation_errs": "0"
> >     }
> >   },
> > }

Hi David!
Thanks for review.

> 
> The overall structure looks good, ie. the separate object 'device-stats'
> and then the contents. For that the device id should be either key to a
> map, or we can put it into an array (where device id must be present
> too).

Thanks, You mean that devid should be key to json map? And I think that 
using as key is better than using array. Example should be like this.

{
  "__header": {
    "version": "1"
  },
  "device-stats": {
    "1": {
      "devid": "1",
      "device": "/dev/vdb",
      "write_io_errs": "0",
      "read_io_errs": "0",
      "flush_io_errs": "0",
      "corruption_errs": "0",
      "generation_errs": "0"
    }
  },
}

If so, I'll write a new patch for this.

Thanks,
Sidong

> 
> A check if the format is usable you can try to write a sample tool that
> parses some of the data and prints them. So eg. using python or jq and
> print stats of device 1. Which points out that device id is missing for
> example.

  reply	other threads:[~2020-11-01  3:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-04 11:25 [PATCH v2] btrfs-progs: device stats: add json output format Sidong Yang
2020-10-30 17:55 ` David Sterba
2020-11-01  3:26   ` Sidong Yang [this message]
2020-11-01 21:24   ` Sidong Yang

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=20201101032622.GA1015@realwakka \
    --to=realwakka@gmail.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /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).