Change OTMonitor graph duration on web page
Moderator: hvxl
Change OTMonitor graph duration on web page
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
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):
Edit: (2 hours later) This isn't quite enough. Adjustments will also be needed in graph.js.
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>
Schelte
Re: Change OTMonitor graph duration on web page
I tried something similar but failed (the graph itself got longer but not the lines).
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?

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?
Last edited by Astroturf on Mon Nov 13, 2023 9:14 pm, edited 2 times in total.
Re: Change OTMonitor graph duration on web page
---- 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)
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)
- Attachments
-
- OTGW_24h_2.PNG (45.01 KiB) Viewed 3510 times
-
- OTGW_24h_1.PNG (67.67 KiB) Viewed 3510 times
Re: Change OTMonitor graph duration on web page
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
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.
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.
Schelte
Re: Change OTMonitor graph duration on web page
Very nice.
I'm running the last version now with span 86400, will report back.

Re: Change OTMonitor graph duration on web page
No issues encountered.
Thanks again for implementing this, Schelte.
Thanks again for implementing this, Schelte.
