]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
irqtop: support json output format
authorJoe Jin <joe.jin@oracle.com>
Fri, 28 Feb 2025 16:13:33 +0000 (08:13 -0800)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Mar 2025 08:26:20 +0000 (09:26 +0100)
Signed-off-by: Joe Jin <joe.jin@oracle.com>
Cc: Zhenwei Pi <pizhenwei@bytedance.com>
Cc: Sami Kerola <kerolasa@iki.fi>
Cc: Karel Zak <kzak@redhat.com>
bash-completion/irqtop
sys-utils/irqtop.1.adoc
sys-utils/irqtop.c

index d18ef99bbb7ff311c5d94f5acecf23bee2c10540..5faf122e5a1e3ff2c68519aac6a1145efffc4779 100644 (file)
@@ -48,6 +48,7 @@ _irqtop_module()
                        ;;
        esac
        OPTS="  --batch
+               --json
                --cpu-stat
                --cpu-list
                --delay
index 75930f5cfe89e1ec26a97f96c5ccb2a76c907702..880ee190653895770a1363e86c16a0c99ac9dc91 100644 (file)
@@ -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.
 
index 17c7d72cb98c25925a9603b17979a8599c6f4c56..48b65201fba7a0395bbd2c6cc1a78073e9ba5f9e 100644 (file)
@@ -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"),