Signed-off-by: Joe Jin <joe.jin@xxxxxxxxxx> Cc: Zhenwei Pi <pizhenwei@xxxxxxxxxxxxx> Cc: Sami Kerola <kerolasa@xxxxxx> Cc: Karel Zak <kzak@xxxxxxxxxx> --- bash-completion/irqtop | 1 + sys-utils/irqtop.1.adoc | 3 +++ sys-utils/irqtop.c | 8 +++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bash-completion/irqtop b/bash-completion/irqtop index d18ef99bb..5faf122e5 100644 --- a/bash-completion/irqtop +++ b/bash-completion/irqtop @@ -48,6 +48,7 @@ _irqtop_module() ;; esac OPTS=" --batch + --json --cpu-stat --cpu-list --delay diff --git a/sys-utils/irqtop.1.adoc b/sys-utils/irqtop.1.adoc index 75930f5cf..880ee1906 100644 --- a/sys-utils/irqtop.1.adoc +++ b/sys-utils/irqtop.1.adoc @@ -37,6 +37,9 @@ Specify cpus in list format to show. *-d*, *--delay* _seconds_:: Update interrupt output every _seconds_ intervals. +*-J*, *--json*:: +Use JSON output format. irqtop will run in batch mode. + *-n*, *--iter* _number_:: Specifies the maximum iterations before quitting. diff --git a/sys-utils/irqtop.c b/sys-utils/irqtop.c index 17c7d72cb..48b65201f 100644 --- a/sys-utils/irqtop.c +++ b/sys-utils/irqtop.c @@ -302,6 +302,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -c, --cpu-stat <mode> show per-cpu stat (auto, enable, disable)\n"), stdout); fputs(_(" -C, --cpu-list <list> specify cpus in list format\n"), stdout); fputs(_(" -d, --delay <secs> delay updates\n"), stdout); + fputs(_(" -J, --json use JSON output format (will run in batch mode)\n"), stdout); fputs(_(" -n, --iter <number> the maximum number of iterations\n"), stdout); fputs(_(" -o, --output <list> define which output columns to use\n"), stdout); fputs(_(" -s, --sort <column> specify sort column\n"), stdout); @@ -336,6 +337,7 @@ static void parse_args( struct irqtop_ctl *ctl, {"cpu-list", required_argument, NULL, 'C'}, {"delay", required_argument, NULL, 'd'}, {"iter", required_argument, NULL, 'n'}, + {"json", no_argument, NULL, 'J'}, {"sort", required_argument, NULL, 's'}, {"output", required_argument, NULL, 'o'}, {"softirq", no_argument, NULL, 'S'}, @@ -346,7 +348,7 @@ static void parse_args( struct irqtop_ctl *ctl, }; int o; - while ((o = getopt_long(argc, argv, "bc:C:d:n:o:s:St:hV", longopts, NULL)) != -1) { + while ((o = getopt_long(argc, argv, "bc:C:d:Jn:o:s:St:hV", longopts, NULL)) != -1) { switch (o) { case 'b': ctl->batch = 1; @@ -386,6 +388,10 @@ static void parse_args( struct irqtop_ctl *ctl, ctl->timer.it_value = ctl->timer.it_interval; } break; + case 'J': + out->json = 1; + ctl->batch = 1; + break; case 'n': ctl->iter = str2num_or_err(optarg, 10, _("failed to parse iter argument"), -- 2.43.5