irqtop: use -J for JSON

* add -J to the man page
* add note about default output
* be compatible with another util-linux tools and use -J

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2020-03-04 14:58:18 +01:00
parent 0d8ead9327
commit f5377ca454
2 changed files with 11 additions and 3 deletions

View file

@ -8,6 +8,10 @@ irqtop \- utility to display kernel interrupt information
Display kernel interrupt counter information in
.BR top (1)
style view.
.PP
The default output is subject to change. So whenever
possible, you should avoid using default outputs in your scripts. Always explicitly define expected columns
by using \fB\-\-columns\fR.
.SH OPTIONS
.TP
.BR \-d ,\ \-\-delay\ \c
@ -16,6 +20,10 @@ Update interrupt output every
.I seconds
intervals.
.TP
.BR \-J ,\ \-\-json
Use JSON output format. It's strongly recommended to use --columns to keep
the output stable.
.TP
.BR \-o ,\ \-\-once
Collect interrupt information and output it. This mode does not use
ncurses, so the output can easily be redirected to a pipe, file, or such.

View file

@ -628,7 +628,7 @@ static void parse_args(struct irqtop_ctl *const ctl, int const argc,
{"delay", required_argument, NULL, 'd'},
{"sort", required_argument, NULL, 's'},
{"once", no_argument, NULL, 'o'},
{"json", no_argument, NULL, JSON_OPT},
{"json", no_argument, NULL, 'J'},
{"columns", required_argument, NULL, COLUMNS_OPT},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
@ -636,7 +636,7 @@ static void parse_args(struct irqtop_ctl *const ctl, int const argc,
};
int o;
while ((o = getopt_long(argc, argv, "d:os:hV", longopts, NULL)) != -1) {
while ((o = getopt_long(argc, argv, "d:os:hJV", longopts, NULL)) != -1) {
switch (o) {
case 'd':
{
@ -655,7 +655,7 @@ static void parse_args(struct irqtop_ctl *const ctl, int const argc,
ctl->run_once = 1;
ctl->request_exit = 1;
break;
case JSON_OPT:
case 'J':
ctl->json = 1;
ctl->run_once = 1;
ctl->request_exit = 1;