mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
chpstat: Adapt to new JSON Lines text format
util_fmt now provides support for JSON Lines text format. Adapt certain checks in the code and document the newly supported format in the man page accordingly. Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
@@ -384,6 +384,17 @@ with an ASCII Record Separator character (0x1e) and suffixed with an ASCII Line
|
||||
Feed character (0x0a) in accordance with RFC7464.
|
||||
.br
|
||||
|
||||
See section "OUTPUT FORMAT" for more details.
|
||||
.BR
|
||||
.PP
|
||||
.IP \(bu 3
|
||||
.B jsonl:
|
||||
Line-delimited JSON data structures
|
||||
|
||||
Data for each iteration is formatted as a single JSON data structure separated
|
||||
by an ASCII Line Feed character (0x0a, LF).
|
||||
.BR
|
||||
|
||||
See section "OUTPUT FORMAT" for more details.
|
||||
.br
|
||||
.PP
|
||||
@@ -736,6 +747,12 @@ Subsequent objects each represent channel-path statistics data for one iteration
|
||||
.br
|
||||
.PP
|
||||
|
||||
.SS jsonl
|
||||
|
||||
The jsonl output format is a data streaming variation of the JSON output format
|
||||
described above with the same properties as the json\-seq output with the
|
||||
difference that JSON data is separated only by an ASCII Line Feed character
|
||||
(0x0a, LF).
|
||||
|
||||
.SH "EXIT CODES"
|
||||
.TP
|
||||
|
||||
@@ -1270,7 +1270,7 @@ static void cmd_list(void)
|
||||
if (opts.groups & KEY_GRP_METRICS)
|
||||
update_util_all(true);
|
||||
|
||||
if (opts.fmt != FMT_JSONSEQ)
|
||||
if (!util_fmt_is_json_stream(opts.fmt))
|
||||
util_fmt_obj_start(FMT_LIST, NULL);
|
||||
for (i = 0; opts.forever || i < opts.iterations; i++) {
|
||||
if (i > 0)
|
||||
@@ -1286,7 +1286,7 @@ static void cmd_list(void)
|
||||
* via pipes (e.g. for use with grep). */
|
||||
fflush(stdout);
|
||||
}
|
||||
if (opts.fmt != FMT_JSONSEQ)
|
||||
if (!util_fmt_is_json_stream(opts.fmt))
|
||||
util_fmt_obj_end();
|
||||
}
|
||||
|
||||
@@ -1972,7 +1972,7 @@ static void init_fmt(void)
|
||||
flags |= FMT_FILTER;
|
||||
if (!opts.use_prefix)
|
||||
flags |= FMT_NOPREFIX;
|
||||
if (opts.fmt == FMT_JSON || opts.fmt == FMT_JSONSEQ) {
|
||||
if (util_fmt_is_json(opts.fmt)) {
|
||||
/* Ensure correct JSON even if interrupted. */
|
||||
flags |= FMT_HANDLEINT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user