[Solved]: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Support questions about the Network Weather Map plugin

Moderators: Developers, Moderators

Post Reply
Dummy
Posts: 24
Joined: Wed Jan 03, 2018 4:35 pm

[Solved]: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Post by Dummy »

I'm using Cacti 1.2.11 and had installed the Weathermap-Plugin provided by phalek (Very great, thank you phalek for adapting weathermap to Cacti 1.x ... :D )
I had defined some Maps which will all work without any problem.

Only one issue is not working and I do not know the reason why. Maybe someone could help?

"Refresh". If I choose one Map on my browser (Firefox, Chrome) it will be displayed immediately.
If I manually refresh the page after about one Minute I will see that the Map was updated (I can see that the timestamp has changed).
But I would expect that there is an automatic refresh of the Webpage to show updated Maps but this will not work.
If I like to see changes on the Map I have to initiate a refresh of the webpage manually.

The Option "Automatically cycle" will work but this is not matching to my needs. I am using 8 Maps and I like to show only 1 Map permanently which should be updated (refreshed) automatically.

In the older Version of Cacti and plugin weathermap there was a config in the <header> - part of the Webpage which takes care on a periodic refresh:
<meta http-equiv=refresh content='300'> ... not in the current Version for Cacti 1.x

Is there no automatic refresh of single Weathermaps?
Last edited by Dummy on Mon Aug 24, 2020 5:30 am, edited 1 time in total.
Dummy
Posts: 24
Joined: Wed Jan 03, 2018 4:35 pm

Re: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Post by Dummy »

The problem was solved already within topic "weathermap 098a_cacti1.x_updated Page refresh issue" :)

I was not aware that my problem was similar to the solved problem but the solution, described in "weathermap 098a_cacti1.x_updated Page refresh issue", works for me too.

Sorry for wasting your time :-?
eyunb0405
Posts: 9
Joined: Tue Sep 27, 2022 11:09 am

Re: [Solved]: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Post by eyunb0405 »

I also have the same problem。

"weathermap 098a_cacti1.x_updated Page refresh issue", didn't works for me. The fix has been corrected in the version I downloaded。
Help, is there any other way to try?

~~~~~~~~~~~~~~~~~~~~~~~~~
vim /var/www/html/cacti/plugins/weathermap/weathermap-cacti-plugin.php
528 if ( $fullscreen ) {
529 print "<script src='" . $config[ 'url_path' ] . "plugins/weathermap/vendor/jquery/dist/jquery.min.js'></script>";
530 }
531 print "<script src='" . $config[ 'url_path' ] . "plugins/weathermap/vendor/jquery-idletimer/dist/idle-timer.min.js'></script>";
~~~~~~~~~~~~~~~~~~~~~~~~
vim /var/www/html/cacti/plugins/weathermap/cacti-resources/map-cycle.js
78 // now that we're done with it, force a reload on the image just
79 // passed
80 WMcycler.forceReload(this);
81 });
82 next.fadeIn(1200);
~~~~~~~~~~~~~~~~~~~~~~~~

cacti 1.2.22 plugin_weathermap-develop
php7.4.30+mariadb10.6.9+RRDtool 1.4.8
amdpowered
Posts: 5
Joined: Tue Nov 08, 2022 1:47 pm

Re: [Solved]: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Post by amdpowered »

I also confirm that the latest version of weathermap 0.98a and Cacti 1.2.22 does not auto refresh when just showing one map. In "fullscreen" cycle mode it does.
amdpowered
Posts: 5
Joined: Tue Nov 08, 2022 1:47 pm

Re: [Solved]: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Post by amdpowered »

As a hack, I added the following to the "cacti/lib/html.php" file in the function html_common_header.

<meta http-equiv=refresh content='30'>

Now it will refresh in 30 seconds.
amdpowered
Posts: 5
Joined: Tue Nov 08, 2022 1:47 pm

Re: [Solved]: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Post by amdpowered »

Actually the previous suggestion is not good because it'll refresh all pages in 30 seconds. The following will refresh only the weathermap single page when not full screen.

I've edited weathermap-cacti-plugin.php and added the following to after line 361 and after line 633.

print "<script>\n";
print "\tfunction autoRefresh() {\n";
print "\t\twindow.location = window.location.href;\n";
print "}\n";
print "setInterval('autoRefresh()',30000);\n";
print "</script>\n";
Last edited by amdpowered on Thu Nov 10, 2022 6:04 am, edited 1 time in total.
eyunb0405
Posts: 9
Joined: Tue Sep 27, 2022 11:09 am

Re: [Solved]: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Post by eyunb0405 »

Dear amdpowered
I don't understand the code, is it added to this location? Maybe the line number of the file is inconsistent with what you describe.
Please help guide the detailed add location.
thanks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
359 print "<tr><td>";
360
361 if ( file_exists( $htmlfile ) ) {
362 print "<script>\n";
363 print "\tfunction autoRefresh() {\n";
364 print "\t\twindow.location = window.location.href;\n";
365 print "}\n"
366 print "setInterval('autoRefresh()',30000);\n"
367 print "</script>\n"

368 echo "<div class='fixscroll' style='overflow:auto'>";
369 include( $htmlfile );
370 echo "</div>";
371 } else {
372 print "<div align=\"center\" style=\"padding:20px\"><em>This map hasn't been created yet.";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
637 }
638
639 if ( file_exists( $htmlfile ) ) {
640 print "<script>\n";
641 print "\tfunction autoRefresh() {\n";
642 print "\t\twindow.location = window.location.href;\n";
643 print "}\n"
644 print "setInterval('autoRefresh()',30000);\n"
645 print "</script>\n"

646 echo "<div class='fixscroll' style='overflow:auto'>";
647 include( $htmlfile );
648 echo "</div>";
649 } else {
650 print "<div align=\"center\" style=\"padding:20px\"><em>This map hasn't been created yet.</em></div>";
651 }
amdpowered
Posts: 5
Joined: Tue Nov 08, 2022 1:47 pm

Re: [Solved]: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Post by amdpowered »

Yes, those locations exactly. Just noticed I was missing 3 semicolons. You can copy and paste the code again and it should work.
eyunb0405
Posts: 9
Joined: Tue Sep 27, 2022 11:09 am

Re: [Solved]: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Post by eyunb0405 »

Dear amdpowered
I applied this code without error. But no automatic refresh is implemented. Open weathermap one map does not refresh automatically.
Are there other modifications required? How should I check? please help。thanks

I tried <meta http-equiv=refresh content='30'> in cacti/lib/html.php , it works fine. The problem is as you describe, all pages will be refreshed.
amdpowered
Posts: 5
Joined: Tue Nov 08, 2022 1:47 pm

Re: [Solved]: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Post by amdpowered »

Did you re-copy and paste the code from above? I had edited it and included 3 missing semicolons.
eyunb0405
Posts: 9
Joined: Tue Sep 27, 2022 11:09 am

Re: [Solved]: Automatic refresh of webpage will not work - Weathermap Cacti1.x

Post by eyunb0405 »

yes, I re-copy and paste the code from above and added ;.
code show as below:

361 if ( file_exists( $htmlfile ) ) {
362 print "<script>\n";
363 print "\tfunction autoRefresh() {\n";
364 print "\t\twindow.location = window.location.href;\n";
365 print "}\n";
366 print "setInterval('autoRefresh()',30000);\n";
367 print "</script>\n";

368 echo "<div class='fixscroll' style='overflow:auto'>";
369 include( $htmlfile );
370 echo "</div>";
371 } else {
~~~~~~~~~~~~~~~~~~~~~~~~
639 if ( file_exists( $htmlfile ) ) {
640 print "<script>\n";
641 print "\tfunction autoRefresh() {\n";
642 print "\t\twindow.location = window.location.href;\n";
643 print "}\n";
644 print "setInterval('autoRefresh()',30000);\n";
645 print "</script>\n";

646 echo "<div class='fixscroll' style='overflow:auto'>";
647 include( $htmlfile );
648 echo "</div>";
649 } else {
~~~~~~~~~~~~~~~~~~~~~~~~
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest