schweikert / fping

High performance ping tool
https://fping.org
Other
1.01k stars 249 forks source link

fping -Q does not output to standard output #262

Closed ziqingkeshi closed 4 months ago

ziqingkeshi commented 2 years ago

Hello, Thank you very much for the program. But I have encountered some problems with using fping,here is my system info:

Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020

When I want to redirect the result of fping -Q command to a file, it didn't work, and output the result to the console,and there is no result in the file either.

image

I tried all kinds of methods, but they didn't work.Finally, I achieved by redirecting stderr:

image

It looks like when "-Q" is used, the output results to standard error. This problem does not occur when the "-Q" parameter is not added, and the results can be obtained from standard output or redirected to a file normally.

I'm not sure if this is an issue and I've been able to achieve what I need, but I still want to figure out this phenomenon.

Looking forward to your reply. Thank you very much!

darless commented 1 year ago

The -Q flag as you say uses stderr. This calls the print_per_system_splits. Using the -N flag uses print_netdata. With -N flag, stdout redirection works without having to redirect stderr. I do not know why it is important to use stderr with print_per_system_splits. I created a PR for this to change to stdout.

schweikert commented 4 months ago

While I agree that fping's use of stdout and stderr is not consistent and could be better, we can't change it now because it would break users calling fping programmatically (i.e. it changes its interface).