Page 1 of 1
RESOLVED: The PHP Errors after the upgrade to R1.3.1
Posted: Sun Nov 17, 2024 10:43 pm
by Ivica Mustapic
After the upgrade of Nagios XI from R1.1.3 to R1.3.1 the Apache error log is filling up with the following error:
[Mon Nov 18 11:40:41.537174 2024] [php:error] [pid 552303] [client 192.168.80.36:57068] PHP Fatal error: Uncaught mysqli_sql_exception:
Unknown column 'service_object_id' in 'where clause' in /usr/local/nrdp/server/plugins/nagioscorepassivecheck/nagioscorepassivecheck.inc.
php:480\nStack trace:\n#0 /usr/local/nrdp/server/plugins/nagioscorepassivecheck/nagioscorepassivecheck.inc.php(480): mysqli->query()\n#1
/usr/local/nrdp/server/plugins/nagioscorepassivecheck/nagioscorepassivecheck.inc.php(162): nrdp_write_check_output_to_ndo()\n#2 /usr/loca
l/nrdp/server/plugins/nagioscorepassivecheck/nagioscorepassivecheck.inc.php(44): nagioscorepassivecheck_submit_check_data()\n#3 /usr/loca
l/nrdp/server/includes/utils.inc.php(560): nagioscorepassivecheck_process_request()\n#4 /usr/local/nrdp/server/index.php(103): do_callbac
ks()\n#5 /usr/local/nrdp/server/index.php(80): route_request()\n#6 {main}\n thrown in /usr/local/nrdp/server/plugins/nagioscorepassivech
eck/nagioscorepassivecheck.inc.php on line 480
We are running Nagios on Ubuntu 22.04.3 LTS!
What would be the best way to resolve this issue?
Also, running db repair process was successful but it did not resolve mentioned issue:
===============
REPAIR COMPLETE
===============
DATABASE: nagiosql
TABLE: /var/lib/mysql/nagiosql ~
DATABASE: nagiosxi
TABLE: /var/lib/mysql/nagiosxi ~
=======================
nagios database repair succeeded
Cheers,
Ivica
Re: The PHP Errors after the upgrade to R1.3.1
Posted: Mon Nov 18, 2024 10:12 am
by lgute
Hi
@Ivica Mustapic,
Thanks for reaching out. I'm going to do a bit of research on this one. At first glance, it seems like a column is missing or there may be a malformed SQL query.
Re: The PHP Errors after the upgrade to R1.3.1
Posted: Tue Nov 19, 2024 2:32 pm
by lgute
Hi
@Ivica Mustapic,
When you ran the repair_databases.sh script, was there a section for table
nagios_servicestatus and what was the output for that section? It should look like
- recovering (with sort) MyISAM-table 'nagios_servicestatus'
Our NRDP developer is looking into this error, in the meantime, would you please run this query, to check if the table has the column and post the results?
Code: Select all
mysql --user=root --password=<mysqlpass from xi-sys.cfg> -e 'describe nagios.nagios_servicestatus';
Re: The PHP Errors after the upgrade to R1.3.1
Posted: Wed Nov 20, 2024 3:10 am
by Ivica Mustapic
Here is the output from mysql query as requested:
+-------------------------------+---------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------------------+---------------+------+-----+---------------------+----------------+
| servicestatus_id | int | NO | PRI | NULL | auto_increment |
| instance_id | smallint | NO | MUL | 0 | |
| service_object_id | int | NO | UNI | 0 | |
| status_update_time | datetime | NO | MUL | 1970-01-01 00:00:01 | |
| output | text | NO | | NULL | |
| long_output | text | NO | | NULL | |
| perfdata | text | NO | | NULL | |
| current_state | smallint | NO | MUL | 0 | |
| has_been_checked | smallint | NO | | 0 | |
| should_be_scheduled | smallint | NO | | 0 | |
| current_check_attempt | smallint | NO | | 0 | |
| max_check_attempts | smallint | NO | | 0 | |
| last_check | datetime | NO | | 1970-01-01 00:00:01 | |
| next_check | datetime | NO | | 1970-01-01 00:00:01 | |
| check_type | smallint | NO | MUL | 0 | |
| check_options | smallint | NO | | 0 | |
| last_state_change | datetime | NO | MUL | 1970-01-01 00:00:01 | |
| last_hard_state_change | datetime | NO | | 1970-01-01 00:00:01 | |
| last_hard_state | smallint | NO | | 0 | |
| last_time_ok | datetime | NO | | 1970-01-01 00:00:01 | |
| last_time_warning | datetime | NO | | 1970-01-01 00:00:01 | |
| last_time_unknown | datetime | NO | | 1970-01-01 00:00:01 | |
| last_time_critical | datetime | NO | | 1970-01-01 00:00:01 | |
| state_type | smallint | NO | MUL | 0 | |
| last_notification | datetime | NO | | 1970-01-01 00:00:01 | |
| next_notification | datetime | NO | | 1970-01-01 00:00:01 | |
| no_more_notifications | smallint | NO | | 0 | |
| notifications_enabled | smallint | NO | MUL | 0 | |
| problem_has_been_acknowledged | smallint | NO | MUL | 0 | |
| acknowledgement_type | smallint | NO | | 0 | |
| current_notification_number | smallint | NO | | 0 | |
| passive_checks_enabled | smallint | NO | MUL | 0 | |
| active_checks_enabled | smallint | NO | MUL | 0 | |
| event_handler_enabled | smallint | NO | MUL | 0 | |
| flap_detection_enabled | smallint | NO | MUL | 0 | |
| is_flapping | smallint | NO | MUL | 0 | |
| percent_state_change | double | NO | MUL | 0 | |
| latency | double | NO | MUL | 0 | |
| execution_time | double | NO | MUL | 0 | |
| scheduled_downtime_depth | smallint | NO | MUL | 0 | |
| failure_prediction_enabled | smallint | NO | | 0 | |
| process_performance_data | smallint | NO | | 0 | |
| obsess_over_service | smallint | NO | | 0 | |
| modified_service_attributes | int | NO | | 0 | |
| event_handler | varchar(255) | NO | | | |
| check_command | varchar(2048) | NO | | | |
| normal_check_interval | double | NO | | 0 | |
| retry_check_interval | double | NO | | 0 | |
| check_timeperiod_object_id | int | NO | | 0 | |
+-------------------------------+---------------+------+-----+---------------------+----------------+
Re: The PHP Errors after the upgrade to R1.3.1
Posted: Wed Nov 20, 2024 10:36 am
by lgute
Hi
@Ivica Mustapic,
Thank you for the information.
The column is in your nagios_servicestatus table. Looking at the code in
/usr/local/nrdp/server/plugins/nagioscorepassivecheck/nagioscorepassivecheck.inc.php, it is possible the logic is allowing the query to run on tables with similar names, that do not have the
service_object_id column.
An Issue has been created and will appear with the tag [GL:XI#1389] in the XI Changelog, when it has been fixed.
If you want a workaround, you could edit nagioscorepassivecheck.inc.php file (see below) and probably not hurt anything. Assuming the rest of the code in that function is supposed to run. Wrap the query on line #480 with an
if block. The example is at the bottom of the code block, so you may have to scroll.
Code: Select all
$sql = "UPDATE nagios_{$type}status
SET status_update_time = FROM_UNIXTIME({$time}),
has_been_checked = 1,
output = '{$output}',
long_output = '{$long_output}',
current_state = {$state},
state_type = {$state_type},
last_check = FROM_UNIXTIME({$time}),
check_type = 1,
execution_time = 0,
{$update_status_sql}
latency = 0
WHERE service_object_id = {$object_id}";
# ONLY run for type "service"
if ($type == "service") {
$db->query($sql); # line #480
}
If you make this change, please let me know how it goes.
Re: The PHP Errors after the upgrade to R1.3.1
Posted: Sun Nov 24, 2024 9:15 pm
by Ivica Mustapic
I have deployed suggested workaround and that has stopped error messages. Thanks for that!
Please consider this closed!
Cheers
Ivica