From: Joe Jin Date: Fri, 28 Feb 2025 16:13:33 +0000 (-0800) Subject: irqtop: support json output format X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=40092a872752c86a0a7459ce5f44f7e51d2fa8b9;p=thirdparty%2Futil-linux.git irqtop: support json output format Signed-off-by: Joe Jin Cc: Zhenwei Pi Cc: Sami Kerola Cc: Karel Zak --- 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 show per-cpu stat (auto, enable, disable)\n"), stdout); fputs(_(" -C, --cpu-list specify cpus in list format\n"), stdout); fputs(_(" -d, --delay delay updates\n"), stdout); + fputs(_(" -J, --json use JSON output format (will run in batch mode)\n"), stdout); fputs(_(" -n, --iter the maximum number of iterations\n"), stdout); fputs(_(" -o, --output define which output columns to use\n"), stdout); fputs(_(" -s, --sort 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"),