Cacti / cacti

Cacti ™
http://www.cacti.net
GNU General Public License v2.0
1.65k stars 406 forks source link

After update 1.1.38 - 1.2 - PHP ERROR NOTICE Backtrace #2353

Closed ISekan closed 5 years ago

ISekan commented 5 years ago

-- 29-Jan-2019 12:45:06 - CMDPHP PHP ERROR NOTICE Backtrace: (/graph_realtime.php[178]:rrdtool_function_graph(), /lib/rrd.php[1791]:rrd_substitute_host_query_data(), /lib/rrd.php[2372]:substitute_host_data(), /lib/variables.php[224]:CactiErrorHandler()) 29-Jan-2019 12:45:06 - ERROR PHP NOTICE: Undefined index: location in file: /var/www/html/cacti/lib/variables.php on line: 224

netniV commented 5 years ago

Please run

desc host;

There should be a location column. The two places that 'sess_host_cache_array' data is set, uses a select * from host with a filter on the host id, so you should always have the location value.

How did you update to 1.2?

ISekan commented 5 years ago

just replaced files in cacti directory and run update wizard. I immediately used ver 1.2.1. It doesen't matter or I should use 1.2ver for upgrage 1.1.38?

cigamit commented 5 years ago

For whatever reason, it looks like the database upgrade script did not complete. In the cli directory there is a script called upgrade_database.php, run it using the forcever=1.1.38.

netniV commented 5 years ago

It's possible that you previously ran an upgrade to the 1.2 beta's? If so, that means it wouldn't reapply the upgrade. run the upgrade above as @cigamit suggested to make sure it wasn't that.

ISekan commented 5 years ago

I tried to run the script. Didn't help. I upgraded from 1.1.38 > 1.2.1. Didn't use beta.

netniV commented 5 years ago

Please run desc host in your mysql instance to show the table description.

ISekan commented 5 years ago
MariaDB [cacti]> desc host;
+------------------------+-----------------------+------+-----+---------------------+-------------------------------+
| Field                  | Type                  | Null | Key | Default             | Extra                         |
+------------------------+-----------------------+------+-----+---------------------+-------------------------------+
| id                     | mediumint(8) unsigned | NO   | PRI | NULL                | auto_increment                |
| poller_id              | int(10) unsigned      | NO   | MUL | 1                   |                               |
| site_id                | int(10) unsigned      | NO   | MUL | 1                   |                               |
| host_template_id       | mediumint(8) unsigned | NO   |     | 0                   |                               |
| description            | varchar(150)          | NO   |     |                     |                               |
| hostname               | varchar(100)          | YES  | MUL |                     |                               |
| notes                  | text                  | YES  |     | NULL                |                               |
| external_id            | varchar(40)           | YES  | MUL | NULL                |                               |
| snmp_community         | varchar(100)          | YES  |     | NULL                |                               |
| snmp_version           | tinyint(1) unsigned   | NO   |     | 1                   |                               |
| snmp_username          | varchar(50)           | YES  |     | NULL                |                               |
| snmp_password          | varchar(50)           | YES  |     | NULL                |                               |
| snmp_auth_protocol     | char(6)               | YES  |     |                     |                               |
| snmp_priv_passphrase   | varchar(200)          | YES  |     |                     |                               |
| snmp_priv_protocol     | char(6)               | YES  |     |                     |                               |
| snmp_context           | varchar(64)           | YES  |     |                     |                               |
| snmp_engine_id         | varchar(64)           | YES  |     |                     |                               |
| snmp_port              | mediumint(5) unsigned | NO   |     | 161                 |                               |
| snmp_timeout           | mediumint(8) unsigned | NO   |     | 500                 |                               |
| snmp_sysDescr          | varchar(300)          | NO   |     |                     |                               |
| snmp_sysObjectID       | varchar(128)          | NO   |     |                     |                               |
| snmp_sysUpTimeInstance | int(10) unsigned      | NO   |     | 0                   |                               |
| snmp_sysContact        | varchar(300)          | NO   |     |                     |                               |
| snmp_sysName           | varchar(300)          | NO   |     |                     |                               |
| snmp_sysLocation       | varchar(300)          | NO   |     |                     |                               |
| availability_method    | smallint(5) unsigned  | NO   |     | 1                   |                               |
| ping_method            | smallint(5) unsigned  | YES  |     | 0                   |                               |
| ping_port              | int(12) unsigned      | YES  |     | 0                   |                               |
| ping_timeout           | int(12) unsigned      | YES  |     | 500                 |                               |
| ping_retries           | int(12) unsigned      | YES  |     | 2                   |                               |
| max_oids               | int(12) unsigned      | YES  |     | 10                  |                               |
| device_threads         | tinyint(2) unsigned   | NO   |     | 1                   |                               |
| disabled               | char(2)               | YES  | MUL |                     |                               |
| thold_send_email       | int(10)               | NO   |     | 1                   |                               |
| thold_host_email       | int(10)               | YES  |     | NULL                |                               |
| status                 | tinyint(2)            | NO   | MUL | 0                   |                               |
| status_event_count     | mediumint(8) unsigned | NO   |     | 0                   |                               |
| status_fail_date       | timestamp             | NO   |     | 0000-00-00 00:00:00 |                               |
| status_rec_date        | timestamp             | NO   |     | 0000-00-00 00:00:00 |                               |
| status_last_error      | varchar(255)          | YES  |     |                     |                               |
| min_time               | decimal(10,5)         | YES  |     | 9.99999             |                               |
| max_time               | decimal(10,5)         | YES  |     | 0.00000             |                               |
| cur_time               | decimal(10,5)         | YES  |     | 0.00000             |                               |
| avg_time               | decimal(10,5)         | YES  |     | 0.00000             |                               |
| polling_time           | double                | YES  |     | 0                   |                               |
| total_polls            | int(12) unsigned      | YES  |     | 0                   |                               |
| failed_polls           | int(12) unsigned      | YES  |     | 0                   |                               |
| availability           | decimal(8,5)          | NO   |     | 100.00000           |                               |
| last_updated           | timestamp             | NO   |     | current_timestamp() | on update current_timestamp() |
netniV commented 5 years ago

It doesn't lie, location is in fact missing.

netniV commented 5 years ago

Please replace <website user> with the user your site runs as and execute the following:

sudo -u <website user> php -q cli/upgrade_database.php -forcever=1.1.38

This was added as part of the 1.2.0 upgrade file:

$ grep "location" * -w
1_2_0.php:      db_install_add_column('host', array('name' => 'location', 'type' => 'varchar(40)', 'after' => 'hostname'));
1_2_0.php:      db_install_add_key('host', 'index', 'site_id_location', array('site_id', 'location'));
ISekan commented 5 years ago

Thanks. Will Cacti work on ver 1.1.38 after this upgrade db? I'm planning to update to 1.2 a bit later

netniV commented 5 years ago

You must already be on 1-2 or above as you are having errors trying to access the location field.

cigamit commented 5 years ago

I suggest if you want to revert to a prior release, that you make a backup of your database first, and then do the revert of it if you have to. Since we all know the solution to this problem, I will close it now.