[packages/nagios] Rel 4; theme independent refresh
arekm
arekm at pld-linux.org
Tue Mar 17 19:49:40 CET 2026
commit 929e55912a46ecb60933507da6a26f3ebde874f9
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Tue Mar 17 19:49:31 2026 +0100
Rel 4; theme independent refresh
nagios-resilient-refresh.patch | 112 ++++++++++++++++++++---------------------
nagios.spec | 2 +-
2 files changed, 55 insertions(+), 59 deletions(-)
---
diff --git a/nagios.spec b/nagios.spec
index 62be271..bd749c5 100644
--- a/nagios.spec
+++ b/nagios.spec
@@ -13,7 +13,7 @@ Summary(pl.UTF-8): Program do monitorowania serwerów/usług/sieci
Summary(pt_BR.UTF-8): Programa para monitoração de máquinas e serviços
Name: nagios
Version: 4.5.11
-Release: 3
+Release: 4
License: GPL v2+
Group: Networking
# https://www.nagios.org/downloads/nagios-core/thanks/?product_download=nagioscore-source
diff --git a/nagios-resilient-refresh.patch b/nagios-resilient-refresh.patch
index 11543f6..15737ca 100644
--- a/nagios-resilient-refresh.patch
+++ b/nagios-resilient-refresh.patch
@@ -6,12 +6,12 @@ lacks the header, permanently breaking the refresh cycle. Browser error
pages (e.g. chrome-error://chromewebdata/) also make the iframe
cross-origin, blocking both reload() and src assignment from the parent.
-The fix has two parts:
-1. index.php (parent frame, never reloads) exposes a nagiosSetRefresh()
- function that manages a fallback timer for the content iframe.
-2. display_info_table() in cgiutils.c calls nagiosSetRefresh(rate) for
- pages that auto-refresh (refresh==TRUE) and nagiosSetRefresh(0) for
- pages that don't, so the timer is only active on the right pages.
+display_info_table() in cgiutils.c now emits a self-contained script
+that installs a nagiosSetRefresh() function on the parent frame (using
+parent.setTimeout so timers survive iframe reloads) and calls it with
+refresh_rate for auto-refreshing pages or 0 for non-refreshing pages.
+The function is installed from the iframe via same-origin access, so it
+works with any theme's index.php without patching it.
The fallback timer fires at 2x the refresh interval, so it only acts
when the CGI's own Refresh header has failed. On success, the reloaded
@@ -19,60 +19,56 @@ page calls nagiosSetRefresh() again, resetting the cycle. On failure,
the iframe element is replaced entirely to bypass cross-origin
restrictions on browser error pages, then retries at the normal interval.
---- nagios-4.5.11.orig/html/index.php.in 2026-01-14 17:37:45.000000000 +0100
-+++ nagios-4.5.11/html/index.php.in 2026-03-17 00:33:38.626558380 +0100
-@@ -45,6 +45,44 @@ if ($theme != 'dark' && $theme != 'light
- <script LANGUAGE="javascript">
- var n = Math.round(Math.random() * 10000000000);
- document.cookie = "NagFormId=" + n.toString(16);
-+
-+ // Resilient refresh: CGI pages call nagiosSetRefresh(rate) to
-+ // register for auto-refresh. This parent frame persists across
-+ // network outages, so the timer survives even when the content
-+ // iframe fails to load and loses its HTTP Refresh header cycle.
-+ var _nagiosRefreshTimer = null;
-+ var _nagiosRefreshUrl = null;
-+ window.nagiosSetRefresh = function(rate) {
-+ if (_nagiosRefreshTimer) {
-+ clearTimeout(_nagiosRefreshTimer);
-+ _nagiosRefreshTimer = null;
-+ }
-+ if (rate > 0) {
-+ try {
-+ var f = document.querySelector('iframe[name="main"]');
-+ if (f && f.contentWindow)
-+ _nagiosRefreshUrl = f.contentWindow.location.href;
-+ } catch(e) {}
-+ _nagiosRefreshTimer = setTimeout(function doRefresh() {
-+ var f = document.querySelector('iframe[name="main"]');
-+ try {
-+ if (f && f.contentWindow)
-+ f.contentWindow.location.reload();
-+ } catch(e) {
-+ // Browser error pages (e.g. chrome-error://) make
-+ // the iframe cross-origin, blocking reload() and
-+ // src assignment. Replace the element entirely.
-+ if (f && _nagiosRefreshUrl) {
-+ var nf = document.createElement('iframe');
-+ nf.name = 'main';
-+ nf.src = _nagiosRefreshUrl;
-+ f.parentNode.replaceChild(nf, f);
-+ }
-+ }
-+ _nagiosRefreshTimer = setTimeout(doRefresh, rate * 1000);
-+ }, rate * 2 * 1000);
-+ }
-+ };
- </script>
-
- <style>
--- nagios-4.5.11.orig/cgi/cgiutils.c 2026-01-14 17:37:45.000000000 +0100
-+++ nagios-4.5.11/cgi/cgiutils.c 2026-03-17 00:33:55.000000000 +0100
-@@ -1658,6 +1658,8 @@
- printf("Last Updated: %s<BR>\n", date_time);
++++ nagios-4.5.11/cgi/cgiutils.c 2026-03-17 19:27:47.303210420 +0100
+@@ -1659,6 +1659,50 @@ void display_info_table(const char *titl
if(refresh == TRUE)
printf("Updated every %d seconds<br>\n", refresh_rate);
-+ printf("<script>if(parent&&parent.nagiosSetRefresh)parent.nagiosSetRefresh(%d);</script>\n",
-+ refresh == TRUE ? refresh_rate : 0);
++ /* Resilient refresh: install a fallback timer on the parent frame
++ that reloads the content iframe when the HTTP Refresh header cycle
++ breaks (network outage, 504, etc). Uses parent.setTimeout so timers
++ survive iframe reloads. Works with any theme's index.php. */
++ printf("<script>\n"
++ "(function() {\n"
++ " var p = parent;\n"
++ " if (!p || p === window) return;\n"
++ " if (!p._nagiosRefreshSetup) {\n"
++ " p._nagiosRefreshSetup = true;\n"
++ " p._nagiosRefreshTimer = null;\n"
++ " p._nagiosRefreshUrl = null;\n"
++ " p.nagiosSetRefresh = function(rate) {\n"
++ " if (p._nagiosRefreshTimer) {\n"
++ " p.clearTimeout(p._nagiosRefreshTimer);\n"
++ " p._nagiosRefreshTimer = null;\n"
++ " }\n"
++ " if (rate > 0) {\n"
++ " try {\n"
++ " var f = p.document.querySelector('iframe[name=\"main\"]');\n"
++ " if (f && f.contentWindow)\n"
++ " p._nagiosRefreshUrl = f.contentWindow.location.href;\n"
++ " } catch(e) {}\n"
++ " p._nagiosRefreshTimer = p.setTimeout(function doRefresh() {\n"
++ " var f = p.document.querySelector('iframe[name=\"main\"]');\n"
++ " try {\n"
++ " if (f && f.contentWindow) f.contentWindow.location.reload();\n"
++ " } catch(e) {\n"
++ " if (f && p._nagiosRefreshUrl) {\n"
++ " var nf = p.document.createElement('iframe');\n"
++ " nf.name = 'main';\n"
++ " nf.src = p._nagiosRefreshUrl;\n"
++ " f.parentNode.replaceChild(nf, f);\n"
++ " }\n"
++ " }\n"
++ " p._nagiosRefreshTimer = p.setTimeout(doRefresh, rate * 1000);\n"
++ " }, rate * 2 * 1000);\n"
++ " }\n"
++ " };\n"
++ " }\n"
++ " p.nagiosSetRefresh(%d);\n"
++ "})();\n"
++ "</script>\n", refresh == TRUE ? refresh_rate : 0);
++
printf("Nagios® Core™ %s - <A HREF='https://www.nagios.org' TARGET='_new' REL='nofollow' CLASS='homepageURL'>www.nagios.org</A><BR>\n", PROGRAM_VERSION);
+
+ if(current_authdata != NULL)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/nagios.git/commitdiff/929e55912a46ecb60933507da6a26f3ebde874f9
More information about the pld-cvs-commit
mailing list