public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Jin <joe.jin@oracle.com>
To: Karel Zak <kzak@redhat.com>, Zhenwei Pi <pizhenwei@bytedance.com>,
	Sami Kerola <kerolasa@iki.fi>
Cc: util-linux@vger.kernel.org, Joe Jin <joe.jin@oracle.com>
Subject: [PATCH V2 3/4] irqtop: support json output format
Date: Fri, 28 Feb 2025 08:13:33 -0800	[thread overview]
Message-ID: <20250228161334.82987-4-joe.jin@oracle.com> (raw)
In-Reply-To: <20250228161334.82987-1-joe.jin@oracle.com>

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  | 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


  parent reply	other threads:[~2025-02-28 16:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28 16:13 [PATCH V2 0/4] irqtop,lsirq: Miscellaneous enhancements Joe Jin
2025-02-28 16:13 ` [PATCH V2 1/4] irqtop: add batch mode support Joe Jin
2025-02-28 16:13 ` [PATCH V2 2/4] irqtop: add max iteration support Joe Jin
2025-03-03  9:39   ` zhenwei pi
2025-03-04  1:39     ` Joe Jin
2025-03-04  3:49       ` zhenwei pi
2025-02-28 16:13 ` Joe Jin [this message]
2025-02-28 16:13 ` [PATCH V2 4/4] lsirq: add support for reading data from given file Joe Jin
2025-03-03 10:16 ` [PATCH V2 0/4] irqtop,lsirq: Miscellaneous enhancements Karel Zak
2025-03-04  1:38   ` Joe Jin
2025-03-04  3:50     ` zhenwei pi
2025-03-04 10:58 ` Karel Zak
2025-03-05  2:23   ` Joe Jin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250228161334.82987-4-joe.jin@oracle.com \
    --to=joe.jin@oracle.com \
    --cc=kerolasa@iki.fi \
    --cc=kzak@redhat.com \
    --cc=pizhenwei@bytedance.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox