Page 1 of 1

Possible bug in map.php on RHEL 8.5 from EPEL 8

Posted: Wed Jan 26, 2022 5:58 pm
by ttytreker
Greetings all,

I'm new here but have been using Nagios Core for many years. I have recently been upgrading my servers from CentOS 7/8 to RHEL 7/8 given the upcoming changes to the CentOS platform. During the migration of my monitoring server (CentOS 7.9) to a clean install of RHEL 8.5 I have discovered a problem with the maps display.

Relevant information:
Nagios Core v4.4.6 RPM install from EPEL 8.
Web server Apache v2.4.37 w/ PHP-FPM v7.2.24.
SELinux enforcing.

Observations:
The default Nagios install runs from Alias "/nagios" and ScriptAlias "/nagios/cgi-bin".
This configuration works as expected and without issue.

I have always run Nagios Core from Alias "/monitor" and ScriptAlias "/monitor/cgi-bin" without issue until now.
From this configuration all works correctly except the new map function which results in a blank page (display). The Legacy map works correctly.

The information button in the top-left corner shows:
Network Map for All Hosts
Last Updated: none
NagiosĀ® Coreā„¢ - http://www.nagios.org
Updated every 10 seconds
Warning: Monitoring process may not be running!
Click here for more info.

View Status Detail For All Hosts
View Status Overview For All Hosts


And the side bar map link is:
https://192.168.5.241/monitor/map.php?host=all
(During configuration the server is restricted to a private IP while the "real" monitor is in operation)
(Once the bugs are sorted out the server will respond to a valid FQDN)

The log files show the following (emphasis added):
192.168.5.27 - - [26/Jan/2022:16:24:44 -0600] "GET /monitor/map.php?host=all HTTP/1.1" 200 2896 "https://192.168.5.241/monitor/side.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
192.168.5.27 - - [26/Jan/2022:16:24:44 -0600] "GET /nagios/cgi-bin/statusjson.cgi?query=programstatus HTTP/1.1" 404 196 "https://192.168.5.241/monitor/map.php?host=all" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
192.168.5.27 - - [26/Jan/2022:16:24:44 -0600] "GET /nagios/cgi-bin/objectjson.cgi?&details=true&formatoptions=enumerate+bitmask&query=hostlist HTTP/1.1" 404 196 "https://192.168.5.241/monitor/map.php?host=all" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"

Notice the correct Alias but incorrect ScriptAlias above.

Links to other CGI calls work correctly, such as Process Info (emphasis added):
192.168.5.27 - - [26/Jan/2022:16:36:45 -0600] "GET /monitor/cgi-bin/extinfo.cgi?type=0 HTTP/1.1" 200 6195 "https://192.168.5.241/monitor/side.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
192.168.5.27 - - [26/Jan/2022:16:36:46 -0600] "GET /monitor/stylesheets/extinfo.css HTTP/1.1" 200 5626 "https://192.168.5.241/monitor/cgi-bin/e ... cgi?type=0" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
192.168.5.27 - - [26/Jan/2022:16:36:46 -0600] "GET /monitor/images/restart.gif HTTP/1.1" 200 260 "https://192.168.5.241/monitor/cgi-bin/e ... cgi?type=0" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
192.168.5.27 - - [26/Jan/2022:16:36:46 -0600] "GET /monitor/images/disabled.gif HTTP/1.1" 200 100 "https://192.168.5.241/monitor/cgi-bin/e ... cgi?type=0" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
192.168.5.27 - - [26/Jan/2022:16:36:46 -0600] "GET /monitor/images/stop.gif HTTP/1.1" 200 246 "https://192.168.5.241/monitor/cgi-bin/e ... cgi?type=0" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"

Notice the correct Alias and ScriptAlias in theses logs...

Relavent config file options-
From cgi.cfg:
main_config_file=/etc/nagios/nagios.cfg
physical_html_path=/usr/share/nagios/html
url_html_path=/monitor
cgi_base_url=/monitor/cgi-bin

From Apache nagios.conf:
ScriptAlias /monitor/cgi-bin/ "/usr/lib64/nagios/cgi-bin/"
<Directory "/usr/lib64/nagios/cgi-bin">
...clipped content...
</Directory>
Alias /monitor/ "/usr/share/nagios/html/"
<Directory "/usr/share/nagios/html">
...clipped content...
</Directory>

I really don't want to hack the source files to make this work and don't want to revert to the default locations because I'm just hard-headed that way. ;)
Any help or guidance would sure be appreciated!

--
Many thanks,
ttytreker

*** UPDATE 27 JAN 2022 ***
Since posting this question, and waiting for moderator review, I have discovered the root of the problem but don't know the proper fix.

There are three .js files in the Nagios root install directory that have hard-coded cgi-bin paths which are correct for the default installation but break the maps if the location is changed.

The culprit files w/line numbers are:

Code: Select all

[root@electra conf.d]# grep -rn "\/nagios\/cgi-bin" /usr/share/nagios/html/*
/usr/share/nagios/html/config.inc.php:7:		$cfg['cgi_base_url']='/nagios/cgi-bin';
/usr/share/nagios/html/js/histogram.js:27:		cgiurl: '/nagios/cgi-bin/',
/usr/share/nagios/html/js/trends.js:37:			cgiurl: '/nagios/cgi-bin/',
/usr/share/nagios/html/js/map.js:100:			cgiurl: '/nagios/cgi-bin/',
I believe the proper fix is to replace "cgiurl:" '<hard path>' with "cgiurl:" '<cgi variable path>'.
I also commented "$cfg['cgi_base_url']='/nagios/cgi-bin';" in "config.inc.php" and inserted "cgi_base_url=<my path to cgi-bin>" in /etc/nagios/cgi.cfg which seems to work.

Perhaps a software developer can offer the proper code to replace the hard_path with the correct variable and direct me how to file a bug report so that future updates don't overwrite the fix.

--
Best regards,
ttytreker