fazalmajid / pingwatch

Simple monitoring tool for your Internet connection, pings hosts and reports on availability and trends
BSD 2-Clause "Simplified" License
29 stars 4 forks source link

Feature Request: self updating / moving graph #2

Closed aslmx closed 4 years ago

aslmx commented 4 years ago

As a User, I'd like to open pingwatch in a browser and watch it over time.

Situation now: The graph loads with all existing values If i want to check more recent values that were measured after i openend pingwatch, I need to refresh the page.

Desired behaviour: Pingwatch graph should update itself every x-seconds. Ideally it should take the interval parameter that was used to start the pingwatch instance.

fazalmajid commented 4 years ago

Good idea, with one exception: you do not want the graph to autoscroll if the user selected a specific time period by selecting a date range with the mouse.

I will need to restructure the code to allow incremental updates, it would be very inefficient to send the entire data every minute.

aslmx commented 4 years ago

I just re-read your comment.

Maybe i want the Graph to auto scroll - even when zoomed.

Lets say I keep 14 days of data (either due to auto triggered db housekeeping, or due to new option that you are going to introduce). Maybe i want to keep the 14 days for retrospective diagnostic, but when i use pingwatch as some kind of dashboard, i'm rather interested in the last 30/60/120 minutes as an overview. So in the WebUI i could zoom into this relative timeframe (last x minutes) and still want to see it auto update.

I don't know whether you share this idea or opinion, i'm not sure where you want to go with pingwatch actually :)

I repeat that i really like it for its lean UI and easy to use UX.

And if i need more i could still just find something that feeds into influxdb and then draw nice complicated dashboards with Grafana.

Altough pingwatch would be a nice data collection demon to feed ping results into influx db ;-)

fazalmajid commented 4 years ago

On Sep 22, 2020, at 20:05, aslmx notifications@github.com wrote:

I just re-read your comment.

Maybe i want the Graph to auto scroll - even when zoomed.

Lets say I keep 14 days of data (either due to auto triggered db housekeeping, or due to new option that you are going to introduce). Maybe i want to keep the 14 days for retrospective diagnostic, but when i use pingwatch as some kind of dashboard, i'm rather interested in the last 30/60/120 minutes as an overview. So in the WebUI i could zoom into this relative timeframe (last x minutes) and still want to see it auto update.

Yes. It should autoscroll as long as the end of the zoomed range is the end of the data. But if you zoomed into yesterday (maybe there wa an outage you want to examine), you don’t want it to scroll. So the rule is, if the end of selection is equal to the most recent data, scroll, otherwise freeze.

By the way, I pushed today a change that adds the option pingwatch -display 6h To show only the last 6 hours, no matter how much data is kept in the DB Or if you want 3 days: ping watch -days 3 That way you don’t have to waste your time manually selecting your time window every time you load the page.

At some point I’ll add a proper date picker so you can select your range, but for now I think it’s a reasonable compromise.

I don't know whether you share this idea or opinion, i'm not sure where you want to go with pingwatch actually :)

I’m trying to keep it minimal in terms of deployment and configuration, with sensible defaults. 2 weeks is probably too much.

I repeat that i really like it for its lean UI and easy to use UX.

Thanks!

And if i need more i could still just find something that feeds into influxdb and then draw nice complicated dashboards with Grafana.

Altough pingwatch would be a nice data collection demon to feed ping results into influx db ;-)

They have their own plugin for this. But you can use it for now, and when you upgrade, copy the data from SQLite into InfluxDB so you don’t lose history.

aslmx commented 4 years ago

So the rule is, if the end of selection is equal to the most recent data, scroll, otherwise freeze

Yes, exactly.

By the way, I pushed today a change that adds the option pingwatch -display 6h To show only the last 6 hours, no matter how much data is kept in the DB Or if you want 3 days: ping watch -days 3 That way you don’t have to waste your time manually selecting your time window every time you load the page.

I've seen and built it. Works as expected. Although this would require me to restart pingwatch when i want to see a longer period, so ...

At some point I’ll add a proper date picker so you can select your range, but for now I think it’s a reasonable compromise.

... i guess a date picker to change the default value specified on commandline would really be cool :+1:

For now i keep it at 24hours with housekeeping by sqlite trigger.

fazalmajid commented 4 years ago

FYI, I just pushed pingwatch autoscrolling to Github.

If your selection end is within 5 minutes f the end of the data range, it will automatically autoscroll (I added the 5 minute fudge factor because it is very hard to zoom to the exact end of the graph even using a mouse). If you select a specific window, it will stay static. Data is sent incrementally and uses very little bandwidth (under 1KB per update in my tests).

aslmx commented 4 years ago

Not sure what i'm doing wrong here...

user@host:~/tools/pingwatch# go build
# _/user/tools/pingwatch
./webui.go:88:23: interval.Milliseconds undefined (type *time.Duration has no field or method Milliseconds)

i found: https://github.com/golang/go/issues/5491

And applied it to webui.go

now go build works.

aslmx commented 4 years ago

If your selection end is within 5 minutes f the end of the data range, it will automatically autoscroll (I added the 5 minute fudge factor because it is very hard to zoom to the exact end of the graph even using a mouse). If you select a specific window, it will stay static. Data is sent incrementally and uses very little bandwidth (under 1KB per update in my tests).

I tried it and with adaptions mentioned in my previous comments it works. However as you said, selecting 5 minutes from 24hours is pretty tricky ;)

Can we maybe have a checkbox to enable autoscrolling regardless of the selected interval? (of coruse only if the current selection reaches the end of the data). That would allow to select arbitrary ranges and auto update them (e.g. 1 hour, 2 hours, ...)

fazalmajid commented 4 years ago

That's a good idea, I added the autoscroll checkbox, and if you change your selection zoom, it will set or reset the checkbox based on the previous rules, but you can override them by checking or unchecking the checkbox.

fazalmajid commented 4 years ago

./webui.go:88:23: interval.Milliseconds undefined (type *time.Duration has no field or method Milliseconds)

Yes, time.Duration.Milliseconds() was added in Go 1.13. You can find out which version of Go you have using go version. I would advise you to upgrade as the current version is 1.15 and 1.13 and older are no longer supported nor do they get security fixes. In the meantime I added e187f3eb85dee83eb12f18650d8c984d04db7008 that fixes this using the older API time.Duration.Nanseconds() instead.

fazalmajid commented 4 years ago

We'll make a Go Pro out of you soon...