Page 1 of 1

Change OTMonitor graph duration on web page

Posted: Mon Nov 06, 2023 6:58 pm
by Astroturf
I tried changing the span variable in otmonitor.tcl to 10800 (3 hours) as indicated here. It did not change the graph duration on the web page unfortunately. Is there any way to change the duration? OTMonitor is installed on a headless server and I only interact via the web server.

Re: Change OTMonitor graph duration on web page

Posted: Fri Nov 10, 2023 9:33 pm
by hvxl
Indeed, the web page still has the 2 hours hard-coded. Applying the patch below may fix that (I didn't wait two hours to actually check it):

Code: Select all

index dcbf2a6..16e8d5e 100644
--- a/otmonitor.vfs/docroot/graph.svg.tmpl
+++ b/otmonitor.vfs/docroot/graph.svg.tmpl
@@ -1,6 +1,6 @@
-% global track start gui graph graphdef theme timestamp
+% global track start gui graph graphdef theme timestamp span
 % set now $timestamp
-% set maxx [expr {min(1440, ($now - $start) / 5.) + 25}]
+% set maxx [expr {min($span, $now - $start) / 5. + 25}]
 % if {[info exists graph]} {
 % } elseif {[info exists gui(ch2)] && $gui(ch2)} {
 %     set graph $graphdef
@@ -51,7 +51,7 @@ svg {
 // Clock difference between server and client
 const skew = [clock milliseconds] - Date.now()
 // Start time of the graph
-var start = [expr {max($start, $now - 7200) * 1000}]
+var start = [expr {max($start, $now - $span) * 1000}]
 var ref = performance.timeOrigin + skew - start
 </script>
 <script href="graph.js"></script>
Edit: (2 hours later) This isn't quite enough. Adjustments will also be needed in graph.js.

Re: Change OTMonitor graph duration on web page

Posted: Mon Nov 13, 2023 9:12 pm
by Astroturf
I tried something similar but failed (the graph itself got longer but not the lines). :wink:

Would it be possible to make the timespan configurable since graph.js is not interpreted by Tcl?
Maybe better to move this discussion to Github?

Re: Change OTMonitor graph duration on web page

Posted: Tue Nov 14, 2023 8:02 pm
by Bororo
---- MOD GRAF 24h ----
sudo nano /opt/otmonitor/otmonitor.vfs/otmonitor.tcl
# change set span = 86400 (t.j. 24h)
sudo nano /opt/otmonitor/otmonitor.vfs/docroot/graph.svg.tmpl
# change row 3 to min(86400, (t.j. 24h)

Re: Change OTMonitor graph duration on web page

Posted: Wed Nov 15, 2023 12:08 pm
by Astroturf
Bororo wrote: Tue Nov 14, 2023 8:02 pm ---- MOD GRAF 24h ----
sudo nano /opt/otmonitor/otmonitor.vfs/otmonitor.tcl
# change set span = 86400 (t.j. 24h)
sudo nano /opt/otmonitor/otmonitor.vfs/docroot/graph.svg.tmpl
# change row 3 to min(86400, (t.j. 24h)
I suppose this will not work for the webpage (graph will not update after 2 hours).
The 2 hour timespan is still hard coded in graph.js as hvxl mentions.
https://github.com/hvxl/otmonitor/blob/ ... aph.js#L64

Re: Change OTMonitor graph duration on web page

Posted: Mon Nov 20, 2023 11:02 pm
by hvxl
I think I got it working with the latest commit on github.

Binaries are available via github actions. It's no longer necessary to modify the source to change the span. Just add "span 14400" (or whatever span you want) in the view section of the configuration file.

Let me know if you notice any problems with these changes.

Re: Change OTMonitor graph duration on web page

Posted: Thu Nov 23, 2023 12:17 am
by Astroturf
Very nice. :D I'm running the last version now with span 86400, will report back.

Re: Change OTMonitor graph duration on web page

Posted: Fri Nov 24, 2023 7:17 pm
by Astroturf
No issues encountered.
Thanks again for implementing this, Schelte. :D