dkogan / feedgnuplot

Tool to plot realtime and stored data from the commandline, using gnuplot.
Other
710 stars 37 forks source link

Pruning old data with histograms #29

Closed vladimiroltean closed 7 years ago

vladimiroltean commented 7 years ago

Hi, I'm plotting the ping rtt with a command similar to this: sudo ping -A 172.15.0.3 -D | gawk '$4=="from" && $8~/time=/ && $9=="ms" {gsub(/[\[#\]]/, "", $1); gsub("time=", "", $8); print $1, $8; fflush()}' | feedgnuplot --domain --stream --lines --histogram 0 --binwidth 0.001 --histstyle freq--style 0 "linewidth 2"

This works as expected, but it clogs down at some point because it's keeping all old data. If I add "--xlen 10", gnuplot complains:

gnuplot> plot '-' using (histbin($2)):(1.0) smooth freq notitle linewidth 2
^ line 30480: all points y value undefined!

Am I misunderstanding the functionality? Is this a bug?

Thanks, Vladimir

dkogan commented 7 years ago

Vladimir Oltean notifications@github.com writes:

I'm plotting the ping rtt with a command similar to this:

sudo ping -A 172.15.0.3 -D | gawk '$4=="from" && $8~/time=/ && $9=="ms" {gsub(/[\[#\]]/, "", $1); gsub("time=", "", $8); print $1, $8; fflush()}' | feedgnuplot --domain --stream --lines --histogram 0 --binwidth 0.001 --histstyle freq--style 0 "linewidth 2"

This works as expected, but it clogs down at some point because it's keeping all old data. If I add "--xlen 10", gnuplot complains:

gnuplot> plot '-' using (histbin($2)):(1.0) smooth freq notitle linewidth 2 ^ line 30480: all points y value undefined!

Am I misunderstanding the functionality? Is this a bug?

Hi. I'm not totally sure what you're trying to do, so can't comment on whether it is a bug or not. You want a histogram of ping round-trip timings, and you want it to update as you get more data. Is that ALL you want, or you want other stuff overlaid on top of this histogram?

vladimiroltean commented 7 years ago

Yes, this is all I'm trying to achieve.

dkogan commented 7 years ago

Vladimir Oltean notifications@github.com writes:

Yes, this is all I'm trying to achieve.

I see. You were doing something more complex than what you needed. An updating histogram:

ping -A -D 8.8.8.8 | gawk '$4=="from" && $8~/time=/ && $9=="ms" {gsub(/[[#]]/, "", $1); gsub("time=", "", $8); print $8; fflush()}' | feedgnuplot --stream --histogram 0 --binwidth 0.1

Admittedly, the interaction of histograms with other options isn't good, and more error checking should be added. Currently there's no support of an "xlen" option to make a moving-window type plot for histograms. The invocation you gave should have given a useful error message or something. It would be good to add, but it's not there no. If you send me a patch, we can talk about it :)

vladimiroltean commented 7 years ago

Ok thanks for the answer. For the moment I may work around the issue by using an external program to generate the histograms.

dkogan commented 7 years ago

I made a few updates and this should now work with the sources in master. Look at the example in the manpage.

vladimiroltean commented 7 years ago

Thanks for taking the time to implement this. If I had to nitpick, I'd say that for histograms, --xmin and --xmax have a usefulness of their own, so they shouldn't be mutually exclusive with --xlen. For example, I'd like to be able to trim the histogram to only show rtt times between 0-20ms, and group all the out-of-range values in the first/last bin.

dkogan commented 7 years ago

You're not nitpicking at all. Thanks for the comment; I've pushed a fix. This is a set of features that I haven't been using together so there's untested logic, and I'm glad people are pointing out the deficiencies.