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

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
ssxitoperations
Posts: 4
Joined: Mon Jan 20, 2025 10:31 am

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

Post 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?
User avatar
jmichaelson
Posts: 375
Joined: Wed Aug 23, 2023 1:02 pm

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

Post 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!
Please let us know if you have any other questions or concerns.

-Jason
ssxitoperations
Posts: 4
Joined: Mon Jan 20, 2025 10:31 am

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

Post 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/
MortenSickel
Posts: 4
Joined: Tue Jan 21, 2025 7:07 am

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

Post 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.
Last edited by MortenSickel on Tue Jan 21, 2025 8:16 am, edited 1 time in total.
ssxitoperations
Posts: 4
Joined: Mon Jan 20, 2025 10:31 am

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

Post 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.
danderson

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

Post 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?
MortenSickel
Posts: 4
Joined: Tue Jan 21, 2025 7:07 am

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

Post by MortenSickel »

For my case, it is centOS7, we are in the process of replacing it, but those things take time.
ssxitoperations
Posts: 4
Joined: Mon Jan 20, 2025 10:31 am

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

Post by ssxitoperations »

We also have CentOS 7. I need to find some time to migrate away.
danderson

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

Post 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
Post Reply