All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] misc/ifstat: ignore json_output when run using "-d"
@ 2023-07-10 10:45 Chander Govindarajan
  2023-07-11 20:30 ` Stephen Hemminger
  2023-07-14 16:04 ` Stephen Hemminger
  0 siblings, 2 replies; 5+ messages in thread
From: Chander Govindarajan @ 2023-07-10 10:45 UTC (permalink / raw)
  To: netdev

If ifstat is run with a command like:
ifstat -d 5 -j

subsequent commands (with or without the "-j" flag) fail with:
Aborted (core dumped)

Unsets json_ouput when using the "-d" flag. Also, since the "-d"
daemon behaviour is not immediately obvious, add a 1 line
description in the man page.

Signed-off-by: ChanderG <mail@chandergovind.org>
---
  man/man8/ifstat.8 | 3 +++
  misc/ifstat.c     | 1 +
  2 files changed, 4 insertions(+)

diff --git a/man/man8/ifstat.8 b/man/man8/ifstat.8
index 8cd164dd..2deeb3b5 100644
--- a/man/man8/ifstat.8
+++ b/man/man8/ifstat.8
@@ -16,6 +16,9 @@ by default only shows difference between the last and 
the current call.
  Location of the history files defaults to /tmp/.ifstat.u$UID but may be
  overridden with the IFSTAT_HISTORY environment variable. Similarly, 
the default
  location for xstat (extended stats) is /tmp/.<xstat name>_ifstat.u$UID.
+
+The \-d flag starts a daemon. Subsequent \fBifstat\fP invocations 
connect to
+this daemon to fetch statistics.
  .SH OPTIONS
  .TP
  .B \-h, \-\-help
diff --git a/misc/ifstat.c b/misc/ifstat.c
index f6f9ba50..08f0518b 100644
--- a/misc/ifstat.c
+++ b/misc/ifstat.c
@@ -888,6 +888,7 @@ int main(int argc, char *argv[])
  	sprintf(sun.sun_path+1, "ifstat%d", getuid());

  	if (scan_interval > 0) {
+		json_output = 0;
  		if (time_constant == 0)
  			time_constant = 60;
  		time_constant *= 1000;
-- 
2.36.1.299.gab336e8f1c


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2] misc/ifstat: ignore json_output when run using "-d"
  2023-07-10 10:45 [PATCH iproute2] misc/ifstat: ignore json_output when run using "-d" Chander Govindarajan
@ 2023-07-11 20:30 ` Stephen Hemminger
  2023-07-12  5:09   ` Chander Govindarajan
  2023-07-14 16:04 ` Stephen Hemminger
  1 sibling, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2023-07-11 20:30 UTC (permalink / raw)
  To: Chander Govindarajan; +Cc: netdev

On Mon, 10 Jul 2023 16:15:22 +0530
Chander Govindarajan <mail@chandergovind.org> wrote:

> If ifstat is run with a command like:
> ifstat -d 5 -j
> 
> subsequent commands (with or without the "-j" flag) fail with:
> Aborted (core dumped)
> 
> Unsets json_ouput when using the "-d" flag. Also, since the "-d"
> daemon behaviour is not immediately obvious, add a 1 line
> description in the man page.
> 
> Signed-off-by: ChanderG <mail@chandergovind.org>

Rather than avoiding the problem, why not have ifstat support json in daemon mode?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2] misc/ifstat: ignore json_output when run using "-d"
  2023-07-11 20:30 ` Stephen Hemminger
@ 2023-07-12  5:09   ` Chander Govindarajan
  0 siblings, 0 replies; 5+ messages in thread
From: Chander Govindarajan @ 2023-07-12  5:09 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

Hi,

So, this does solve the problem correctly, in the sense:
1. First you should start ifstat in daemon mode (without -j, with the 
patch, it will anyway be ignored)
2. Then, you can run ifstat in normal or in json mode; where it will 
connect to the daemon, get back results and then print it in the 
required format (table or json).

So, this patch only ensures that the communication between the daemon 
and other instances happen correctly (not in json).

PS: in the process of testing this, I figured out a bug in the -j mode, 
I will submit a separate patch. :-)

Regards,
Chander

On 7/12/23 02:00, Stephen Hemminger wrote:
> On Mon, 10 Jul 2023 16:15:22 +0530
> Chander Govindarajan <mail@chandergovind.org> wrote:
> 
>> If ifstat is run with a command like:
>> ifstat -d 5 -j
>>
>> subsequent commands (with or without the "-j" flag) fail with:
>> Aborted (core dumped)
>>
>> Unsets json_ouput when using the "-d" flag. Also, since the "-d"
>> daemon behaviour is not immediately obvious, add a 1 line
>> description in the man page.
>>
>> Signed-off-by: ChanderG <mail@chandergovind.org>
> 
> Rather than avoiding the problem, why not have ifstat support json in daemon mode?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2] misc/ifstat: ignore json_output when run using "-d"
  2023-07-10 10:45 [PATCH iproute2] misc/ifstat: ignore json_output when run using "-d" Chander Govindarajan
  2023-07-11 20:30 ` Stephen Hemminger
@ 2023-07-14 16:04 ` Stephen Hemminger
  2023-07-17  9:26   ` [PATCH iproute2 v2] " Chander Govindarajan
  1 sibling, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2023-07-14 16:04 UTC (permalink / raw)
  To: Chander Govindarajan; +Cc: netdev

On Mon, 10 Jul 2023 16:15:22 +0530
Chander Govindarajan <mail@chandergovind.org> wrote:

> If ifstat is run with a command like:
> ifstat -d 5 -j
> 
> subsequent commands (with or without the "-j" flag) fail with:
> Aborted (core dumped)
> 
> Unsets json_ouput when using the "-d" flag. Also, since the "-d"
> daemon behaviour is not immediately obvious, add a 1 line
> description in the man page.
> 
> Signed-off-by: ChanderG <mail@chandergovind.org>

Was about to apply this but there a couple of problems.

First, in the Signed-off-by: it should have your legal name.
Is it supposed to be "Chander Govind <mail@chandergovind.org>"?


> ---
>   man/man8/ifstat.8 | 3 +++
>   misc/ifstat.c     | 1 +
>   2 files changed, 4 insertions(+)
> 
> diff --git a/man/man8/ifstat.8 b/man/man8/ifstat.8
> index 8cd164dd..2deeb3b5 100644
> --- a/man/man8/ifstat.8
> +++ b/man/man8/ifstat.8
> @@ -16,6 +16,9 @@ by default only shows difference between the last and 
> the current call.
>   Location of the history files defaults to /tmp/.ifstat.u$UID but may be
>   overridden with the IFSTAT_HISTORY environment variable. Similarly, 
> the default
>   location for xstat (extended stats) is /tmp/.<xstat name>_ifstat.u$UID.

What ever you used to make the patch or send it got messed up here.
There is a missing newline, causing git (and patch) command to report
that this is a malformed patch.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2 v2] misc/ifstat: ignore json_output when run using "-d"
  2023-07-14 16:04 ` Stephen Hemminger
@ 2023-07-17  9:26   ` Chander Govindarajan
  0 siblings, 0 replies; 5+ messages in thread
From: Chander Govindarajan @ 2023-07-17  9:26 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

If ifstat is run with a command like:
ifstat -d 5 -j

subsequenct commands (with or without the "-j" flag) fail with:
Aborted (core dumped)

Unsets json_ouput when using the "-d" flag. Also, since the "-d"
daemon behaviour is not immediately obvious, add a 1 line
description in the man page.

Signed-off-by: Chander Govindarajan <mail@chandergovind.org>
---
 man/man8/ifstat.8 | 3 +++
 misc/ifstat.c     | 1 +
 2 files changed, 4 insertions(+)

diff --git a/man/man8/ifstat.8 b/man/man8/ifstat.8
index 8cd164dd..2deeb3b5 100644
--- a/man/man8/ifstat.8
+++ b/man/man8/ifstat.8
@@ -16,6 +16,9 @@ by default only shows difference between the last and the current call.
 Location of the history files defaults to /tmp/.ifstat.u$UID but may be
 overridden with the IFSTAT_HISTORY environment variable. Similarly, the default
 location for xstat (extended stats) is /tmp/.<xstat name>_ifstat.u$UID.
+
+The \-d flag starts a daemon. Subsequent \fBifstat\fP invocations connect to
+this daemon to fetch statistics.
 .SH OPTIONS
 .TP
 .B \-h, \-\-help
diff --git a/misc/ifstat.c b/misc/ifstat.c
index f6f9ba50..08f0518b 100644
--- a/misc/ifstat.c
+++ b/misc/ifstat.c
@@ -888,6 +888,7 @@ int main(int argc, char *argv[])
 	sprintf(sun.sun_path+1, "ifstat%d", getuid());
 
 	if (scan_interval > 0) {
+		json_output = 0;
 		if (time_constant == 0)
 			time_constant = 60;
 		time_constant *= 1000;
-- 
2.36.1.299.gab336e8f1c

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-17  9:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-10 10:45 [PATCH iproute2] misc/ifstat: ignore json_output when run using "-d" Chander Govindarajan
2023-07-11 20:30 ` Stephen Hemminger
2023-07-12  5:09   ` Chander Govindarajan
2023-07-14 16:04 ` Stephen Hemminger
2023-07-17  9:26   ` [PATCH iproute2 v2] " Chander Govindarajan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.