Page 1 of 2

Unable to Access Nagios Web Interface After Updating Nagios Core to 4.5.9

Posted: Mon Jan 20, 2025 10:40 am
by ssxitoperations
I updated Nagios Core from version 4.5.7 to 4.5.9 by following the instructions at https://assets.nagios.com/downloads/nag ... ading.html.

However, after the update, I cannot access the Nagios web interface. It returns an HTTP Error 500 "This page isn't working and currently unable to handle this request".

Anyone experienced something similar and how to go about resolving?

Re: Unable to Access Nagios Web Interface After Updating Nagios Core to 4.5.9

Posted: Mon Jan 20, 2025 3:57 pm
by jmichaelson
When something like that happens, your best bet is to have a look at the web server error logs. On RHEL/CentOS/Oracle distributions they're most likely under /var/log/php-fpm. On Debian and Ubunto they're most likely under /var/log/apache2. If you attach a snippet of the end of the error log, we'll be able to take a deeper look at it!

Re: Unable to Access Nagios Web Interface After Updating Nagios Core to 4.5.9

Posted: Mon Jan 20, 2025 4:42 pm
by ssxitoperations
jmichaelson wrote: Mon Jan 20, 2025 3:57 pm When something like that happens, your best bet is to have a look at the web server error logs. On RHEL/CentOS/Oracle distributions they're most likely under /var/log/php-fpm. On Debian and Ubunto they're most likely under /var/log/apache2. If you attach a snippet of the end of the error log, we'll be able to take a deeper look at it!
I don't have a /var/log/php-fpm nor do I have a /var/log/apache2 file or folder but I do have a /var/log/httpd/error_log file.

Here are the contents of the error_log (the IP address of the Nagios server is 10.0.0.100):


[Sun Jan 19 03:37:02.366012 2025] [lbmethod_heartbeat:notice] [pid 1148] AH02282: No slotmem from mod_heartmonitor
[Sun Jan 19 03:37:02.412876 2025] [mpm_prefork:notice] [pid 1148] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
[Sun Jan 19 03:37:02.412896 2025] [core:notice] [pid 1148] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Jan 20 09:39:32.751043 2025] [:error] [pid 29188] [client 10.0.10.82:50509] PHP Parse error: syntax error, unexpected '?' in /usr/local/nagios/share/index.php on line 32, referer: http://10.0.0.100/
[Mon Jan 20 09:39:38.110856 2025] [:error] [pid 20384] [client 10.0.10.82:50510] PHP Parse error: syntax error, unexpected '?' in /usr/local/nagios/share/index.php on line 32, referer: http://10.0.0.100/
[Mon Jan 20 09:40:42.447060 2025] [mpm_prefork:notice] [pid 1148] AH00170: caught SIGWINCH, shutting down gracefully
[Mon Jan 20 09:41:08.896502 2025] [suexec:notice] [pid 1154] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Jan 20 09:41:08.953146 2025] [lbmethod_heartbeat:notice] [pid 1154] AH02282: No slotmem from mod_heartmonitor
[Mon Jan 20 09:41:09.163911 2025] [mpm_prefork:notice] [pid 1154] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
[Mon Jan 20 09:41:09.163951 2025] [core:notice] [pid 1154] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Jan 20 09:43:17.096856 2025] [:error] [pid 1472] [client 10.0.10.82:50663] PHP Parse error: syntax error, unexpected '?' in /usr/local/nagios/share/index.php on line 32, referer: http://10.0.0.100/

Re: Unable to Access Nagios Web Interface After Updating Nagios Core to 4.5.9

Posted: Tue Jan 21, 2025 7:18 am
by MortenSickel
I had the same problem the other day. The php code demands a newer version of php than what your server is running. It is using the Null coalescing ?? operator

Code: Select all

 $theme = $cfg['theme'] ?? 'dark';
 if ($theme != 'dark' && $theme != 'light') {
          $theme = 'dark';
  }
I.e. if $cfg['theme'] is set. $theme is set to that value, if it is not set, $theme is set to 'dark'

I did a quite ugly hack,

Code: Select all

//$theme = $cfg['theme'] ?? 'dark';
$theme = '';
if ($theme != 'dark' && $theme != 'light') {
         $theme = 'dark';
}
This is hardcoding theme to dark. I could have written a few lines to get the same function as originally, but I didn't bother. The same operator is used a few other places in the code base to do exactly the same thing, so expect the same error to pop up a few more things or grep for ?? (ie grep \?\? *php) to correct them all.

Re: Unable to Access Nagios Web Interface After Updating Nagios Core to 4.5.9

Posted: Tue Jan 21, 2025 9:51 am
by ssxitoperations
Thanks @MortenSickel !

Your solution fixed it. There are still some quirks, for instance the "Home" page is completely blank, but the rest of the webpages "Services", "Hosts", etc. all are accessible again.

Re: Unable to Access Nagios Web Interface After Updating Nagios Core to 4.5.9

Posted: Tue Jan 21, 2025 11:10 am
by danderson
The null coalescing operator was added to PHP 7, which released around 9 years ago. Which distribution are you using that's using PHP 5?

Re: Unable to Access Nagios Web Interface After Updating Nagios Core to 4.5.9

Posted: Tue Jan 21, 2025 3:28 pm
by MortenSickel
For my case, it is centOS7, we are in the process of replacing it, but those things take time.

Re: Unable to Access Nagios Web Interface After Updating Nagios Core to 4.5.9

Posted: Wed Jan 22, 2025 9:37 am
by ssxitoperations
We also have CentOS 7. I need to find some time to migrate away.

Re: Unable to Access Nagios Web Interface After Updating Nagios Core to 4.5.9

Posted: Wed Jan 22, 2025 11:37 am
by danderson
The null coalescing operator is some syntactic sugar added in PHP 7. From https://www.php.net/manual/en/migration ... atures.php

Code: Select all

<?php
// Fetches the value of $_GET['user'] and returns 'nobody'
// if it does not exist.
$username = $_GET['user'] ?? 'nobody';
// This is equivalent to:
$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';
So you the fix is as follows

Code: Select all

//$theme = $cfg['theme'] ?? 'dark';
$them = isset($cfg['theme]) ? $cfg['theme'] : 'dark';
I'll make this change into Core

Re: Unable to Access Nagios Web Interface After Updating Nagios Core to 4.5.9

Posted: Wed Jan 22, 2025 12:01 pm
by danderson