Page 1 of 1

PHP Warning: feof() expects parameter 1 to be resource

Posted: Tue Feb 16, 2021 11:05 am
by jbaduria
PHP Warning: feof() expects parameter 1 to be resource, boolean given in /usr/local/nagiosxi/scripts/utils-reports.inc.php

It is on line 578:

$fp = popen($binpath, "r");
while (!feof($fp)) { --- Line 578
$rawoutput .= fread($fp, 1024);
}

I think it needs to check for $fp:

$fp = popen($binpath, "r");
if ($fp) {
while (!feof($fp)) {
$rawoutput .= fread($fp, 1024);
}
}

Re: PHP Warning: feof() expects parameter 1 to be resource

Posted: Tue Feb 16, 2021 1:51 pm
by dchurch
Sure, that's a good fix. I'll notify our dev team.

If you're interested in remedying the cause of this error, then read on.

What's the output from the following commands?

Code: Select all

ls -la /usr/local/nagios/sbin/avail.cgi
php -r 'require("/usr/local/nagiosxi/html/config.inc.php");var_dump($cfg["component_info"]["nagioscore"]["cgi_dir"]);'