speedtest-plotter icon indicating copy to clipboard operation
speedtest-plotter copied to clipboard

Time written as xlabel is misleading

Open fekir opened this issue 10 months ago • 5 comments

The time written in the csv file is in the following format:

2025-02-18T11:07:01.958973Z

On the generated svg file, the x-axise goes from $SOMEWHEN_IN_THE_PAST to 2025-02-18\n11:15:00, and it seems as if the measurement was taken at 2025-02-18T11:20:18.

Unfortunately my actual (local) time when speedtest-cli is executed was at 12:20:18

The Gnuplot script also prints when the graphics is plotted, in this case: plotted 2025-02-18 12:07:23 CET.

Is there any chance to have gnuplot convert the x-axis to CET too?

fekir avatar Feb 18 '25 12:02 fekir

The timestamps in the CSV are always stored as UTC, hence the Z at the end. I believe that's what the TZ variable was for, to adjust the timezone during rendering. Not sure where exactly in the CET timezone you live but you could try adding TZ=Europe/Berlin to your config.

ansemjo avatar Feb 18 '25 12:02 ansemjo

I'm executing the gnuplot -c plotscript "manually", and I overlooked it in the readme that you set the TZ env variable in your docker command or when executing plotscript directly.

But I just tested it out; it does not seem to make a difference.

The output of speedtest-cli is unaffected by TZ, and plotscript does not take it into account.

I see that speedtest-plotter uses TZ internally; I'm thus confident that using speedtest-plotter provides a consistent experience.

It would be a nice enhancement if plotscript could work with the csv output of speedtest-cli directly.

fekir avatar Feb 18 '25 15:02 fekir

Aha, I see! Well, there's a couple of problems:

You could use a hack like this, to add an appropriate amount of seconds to the time column in your data. Though that doesn't account for daylight savings either. To do it properly, you'd need to use a script to pre-format the timestamps in your desired timezone – so, exactly what speedtest-plotter is doing. ;)

It won't "fix" the timestamp but you could also add %Z to the xtics format to at least make it apparent that it's showing UTC times (in theory, haven't tested this):

set xtics format "%Y-%m-%d\n%H:%M:%S %Z" out

ansemjo avatar Feb 18 '25 16:02 ansemjo

I see

set xtics format "%Y-%m-%d\n%H:%M:%S %Z" out

does not seem to work, I guess the easiest way is to adapt the csv file then, the suggested workaround, as you mentioned, does not work well with daylight savings.

No idea why it behaves differently for the plot timestamp and the axis labels, though.

Yeah, that was the most confusing part in my setup; I thought my cron job was not running at the correct time until I saw that timestamp.

fekir avatar Feb 18 '25 17:02 fekir

@ansemjo I think you can close the issue, as far as I can see there is nothing to do.

FYI, I just found librespeed-cli(https://github.com/librespeed/speedtest-cli, has the same CLI api of the original speedtest-cli and is already packaged in some distros).

Unfortunately the csv columns are ordered differently, but with it I have no inconsistencies with the timestamps.

It is just a matter of adapting ARG1 using <N> in the plot script.

fekir avatar Mar 07 '25 12:03 fekir