Page 4 of 5

Re: Runtime Error for host and service notification

Posted: Tue Dec 27, 2016 10:44 am
by tgriep
Edit the /etc/php.ini file and change the following line from

Code: Select all

;error_log = php_errors.log
to

Code: Select all

error_log = php_errors.log
Save the file and run the command that fails again.

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php
Hopefully this will log some error in the following file

Code: Select all

/home/nagios/php_errors.log
Please post that file so we can review it.
Also, run the following as root and post the /tmp/ls.txt file.

Code: Select all

ls -lR /usr/local/nagiosxi >/tmp/ls.txt
Thanks

Re: Runtime Error for host and service notification

Posted: Tue Dec 27, 2016 11:40 am
by valmberg
The ls.txt file is attached.

Here is the output:
[27-Dec-2016 08:34:02] PHP Notice: Undefined index: nagiosxi in /usr/local/nagiosxi/html/includes/db.inc.php on line 488
[27-Dec-2016 08:34:02] PHP Warning: Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/includes/components/nagiosim/nagiosim.inc.php on line 489
[27-Dec-2016 08:34:02] PHP Notice: Undefined index: nagiosxi in /usr/local/nagiosxi/html/includes/db.inc.php on line 488
[27-Dec-2016 08:34:02] PHP Notice: Undefined index: nagiosxi in /usr/local/nagiosxi/html/includes/db.inc.php on line 488
[27-Dec-2016 08:34:02] PHP Notice: Undefined index: nagiosxi in /usr/local/nagiosxi/html/includes/db.inc.php on line 488
[27-Dec-2016 08:34:02] PHP Warning: Invalid argument supplied for foreach() in /usr/local/nagiosxi/html/includes/components/nagiosim/nagiosim.inc.php on line 489
[27-Dec-2016 08:34:02] PHP Notice: Undefined index: nagiosxi in /usr/local/nagiosxi/html/includes/db.inc.php on line 488
[27-Dec-2016 08:34:02] PHP Notice: Undefined index: nagiosxi in /usr/local/nagiosxi/html/includes/db.inc.php on line 488

Re: Runtime Error for host and service notification

Posted: Tue Dec 27, 2016 2:37 pm
by tgriep
Edit the /etc/php.ini file again and verify that the following options are set like the example below

Code: Select all

display_errors = On
log_errors = On 
Save the php.ini file and run the following command again

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php
Hopefully this time it will log something in the /home/nagios/php_errors.log file.

Re: Runtime Error for host and service notification

Posted: Tue Dec 27, 2016 3:12 pm
by valmberg
Attached is the PHP error log file.

Here are the settings in the /etc/php.ini file:

; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; It's recommended that errors be logged on production servers rather than
; having the errors sent to STDOUT.
; Possible Values:
; Off = Do not display any errors
; stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
; On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://www.php.net/manual/en/errorfunc. ... lay-errors
display_errors = On

; The display of errors which occur during PHP's startup sequence are handled
; separately from display_errors. PHP's default behavior is to suppress those
; errors from clients. Turning the display of startup errors on can be useful in
; debugging configuration problems. But, it's strongly recommended that you
; leave this setting off on production servers.
; Default Value: Off
; Development Value: On
; Production Value: Off
; http://www.php.net/manual/en/errorfunc. ... tup-errors
display_startup_errors = Off

; Besides displaying errors, PHP can also log errors to locations such as a
; server-specific log, STDERR, or a location specified by the error_log
; directive found below. While errors should not be displayed on productions
; servers they should still be monitored and logging is a great way to do that.
; Default Value: Off
; Development Value: On
; Production Value: On
; http://www.php.net/manual/en/errorfunc. ... log-errors
log_errors = On

Re: Runtime Error for host and service notification

Posted: Tue Dec 27, 2016 4:05 pm
by tgriep
Can you post your /etc/php.ini file so we can view it?
I found this error and another setting in the php.ini file could be the cause.

Code: Select all

[27-Dec-2016 12:08:02] PHP Notice:  Unknown: Cannot set connection to blocking mode in Unknown on line 0

Re: Runtime Error for host and service notification

Posted: Tue Dec 27, 2016 5:08 pm
by valmberg
It's attached.

Re: Runtime Error for host and service notification

Posted: Wed Dec 28, 2016 9:38 am
by tgriep
Can you run the following and post the /tmp/strace.txt file?

Code: Select all

strace /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php &> /tmp/strace.txt

Re: Runtime Error for host and service notification

Posted: Wed Dec 28, 2016 12:41 pm
by valmberg
File is attached.

Re: Runtime Error for host and service notification

Posted: Wed Dec 28, 2016 3:18 pm
by tgriep
Can you replace your /usr/local/nagiosxi/html/config.inc.php file with the one that is attached to the post?
Make sure you make a backup of the original first.

Then run the following commands and see if the echo command returns a 255.

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php
echo $?
If it returns a 0, then the issue should be fixed and you can see if you can get a notification to work on your system.

Re: Runtime Error for host and service notification

Posted: Wed Dec 28, 2016 4:11 pm
by valmberg
Returned a 0 this time (with the new file). Here is the output of the command:

[root@nagios ~]# /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php
Before Call
int(2)
int(2)
handle_event meta
array(0) {
}
execute_sql
string(5) "pgsql"
string(9) "localhost"
string(8) "nagiosxi"
string(6) "n@gweb"
string(8) "nagiosxi"
dsn
string(37) "pgsql:host=localhost;dbname=nagiosxi;"
pdo
object(PDO)#1 (0) {
}
statement
object(PDOStatement)#2 (1) {
["queryString"]=>
string(114) "INSERT INTO xi_eventqueue (event_time, event_source, event_type, event_meta) VALUES (1482959380, 2, 2, 'YTowOnt9')"
}
After Call

You have new mail in /var/spool/mail/root
[root@nagios ~]# echo ?
?
[root@nagios ~]# echo $?
0
[root@nagios ~]# /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php
Before Call
int(2)
int(2)
handle_event meta
array(0) {
}
execute_sql
string(5) "pgsql"
string(9) "localhost"
string(8) "nagiosxi"
string(6) "n@gweb"
string(8) "nagiosxi"
dsn
string(37) "pgsql:host=localhost;dbname=nagiosxi;"
pdo
object(PDO)#1 (0) {
}
statement
object(PDOStatement)#2 (1) {
["queryString"]=>
string(114) "INSERT INTO xi_eventqueue (event_time, event_source, event_type, event_meta) VALUES (1482959431, 2, 2, 'YTowOnt9')"
}
After Call

[root@nagios ~]# echo $?
0
[root@nagios ~]#