Cacti / cacti

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

SQL error when editing device #419

Closed dsclassen closed 7 years ago

dsclassen commented 7 years ago

Tried to change Downed Device Detection and received this error:

Error: Unknown column 'external_id' in 'field list'

Log [Total Lines: 500 - Admin View - No Other Filter in Affect]
2017-03-13 10:37:52 - CMDPHP WARNING: SNMP Error:'Timeout (500 ms)', Device:'192.168.6.1', OID:'.1.3.6.1.2.1.1.1.0'
2017-03-13 10:37:50 - DBCALL ERROR: SQL Save Failed for Table 'host'. SQL:'INSERT INTO host (`id`, `host_template_id`, `poller_id`, `site_id`, `external_id`, `description`, `hostname`, `notes`, `snmp_version`, `snmp_community`, `snmp_username`, `snmp_password`, `snmp_auth_protocol`, `snmp_priv_passphrase`, `snmp_priv_protocol`, `snmp_context`, `snmp_engine_id`, `snmp_port`, `snmp_timeout`, `disabled`, `availability_method`, `ping_method`, `ping_port`, `ping_timeout`, `ping_retries`, `max_oids`, `device_threads`, `monitor`, `monitor_text`, `monitor_criticality`, `monitor_warn`, `monitor_alert`, `thold_send_email`, `thold_host_email`) VALUES (127, 27, 1, 1, '', 'host', '192.168.6.1', 'Added manually through device automation interface.', 2, 'public', '', '', '', '', '', '', '', 161, 500, '', 4, 1, 23, 400, 3, 10, 1, 'on', '', 0, 0, 0, 1, 0) ON DUPLICATE KEY UPDATE `host_template_id`=VALUES(`host_template_id`), `poller_id`=VALUES(`poller_id`), `site_id`=VALUES(`site_id`), `external_id`=VALUES(`external_id`), `description`=VALUES(`description`), `hostname`=VALUES(`hostname`), `notes`=VALUES(`notes`), `snmp_version`=VALUES(`snmp_version`), `snmp_community`=VALUES(`snmp_community`), `snmp_username`=VALUES(`snmp_username`), `snmp_password`=VALUES(`snmp_password`), `snmp_auth_protocol`=VALUES(`snmp_auth_protocol`), `snmp_priv_passphrase`=VALUES(`snmp_priv_passphrase`), `snmp_priv_protocol`=VALUES(`snmp_priv_protocol`), `snmp_context`=VALUES(`snmp_context`), `snmp_engine_id`=VALUES(`snmp_engine_id`), `snmp_port`=VALUES(`snmp_port`), `snmp_timeout`=VALUES(`snmp_timeout`), `disabled`=VALUES(`disabled`), `availability_method`=VALUES(`availability_method`), `ping_method`=VALUES(`ping_method`), `ping_port`=VALUES(`ping_port`), `ping_timeout`=VALUES(`ping_timeout`), `ping_retries`=VALUES(`ping_retries`), `max_oids`=VALUES(`max_oids`), `device_threads`=VALUES(`device_threads`), `monitor`=VALUES(`monitor`), `monitor_text`=VALUES(`monitor_text`), `monitor_criticality`=VALUES(`monitor_criticality`), `monitor_warn`=VALUES(`monitor_warn`), `monitor_alert`=VALUES(`monitor_alert`), `thold_send_email`=VALUES(`thold_send_email`), `thold_host_email`=VALUES(`thold_host_email`)'
2017-03-13 10:37:50 - CMDPHP SQL Backtrace: (/host.php: 53 form_save)(/host.php: 171 api_device_save)(/lib/api_device.php: 193 sql_save)(/lib/database.php: 943 _db_replace)(/lib/database.php: 890 db_execute)(/lib/database.php: 113 db_execute_prepared)(/lib/database.php: 178 cacti_debug_backtrace)
2017-03-13 10:37:50 - CMDPHP ERROR: A DB Exec Failed!, Error: Unknown column 'external_id' in 'field list'
2017-03-13 10:37:50 - DBCALL ERROR: A DB Exec Failed!, Error:1054, SQL:"INSERT INTO host (`id`, `host_template_id`, `poller_id`, `site_id`, `external_id`, `description`, `hostname`, `notes`, `snmp_version`, `snmp_community`, `snmp_username`, `snmp_password`, `snmp_auth_protocol`, `snmp_priv_passphrase`, `snmp_priv_protocol`, `snmp_context`, `snmp_engine_id`, `snmp_port`, `snmp_timeout`, `disabled`, `availability_method`, `ping_method`, `ping_port`, `ping_timeout`, `ping_retries`, `max_oids`, `device_threads`, `monitor`, `monitor_text`, `monitor_criticality`, `monitor_warn`, `monitor_alert`, `thold_send_email`, `thold_host_email`) VALUES (127, 27, 1, 1, '', 'host', '192.168.6.1', 'Added manually through device automation interface.', 2, 'public', '', '', '', '', '', '', '', 161, 500, '', 4, 1, 23, 400, 3, 10, 1, 'on', '', 0, 0, 0, 1, 0) ON DUPLICATE KEY UPDATE `host_template_id`=VALUES(`host_template_id`), `poller_id`=VALUES(`poller_id`), `site_id`=VALUES(`site_id`), `external_id`=VALUES(`external_id`), `description`=VALUES(`description`), `hostname`=VALUES(`hostname`), `notes`=VALUES(`notes`), `snmp_version`=VALUES(`snmp_version`), `snmp_community`=VALUES(`snmp_community`), `snmp_username`=VALUES(`snmp_username`), `snmp_password`=VALUES(`snmp_password`), `snmp_auth_protocol`=VALUES(`snmp_auth_protocol`), `snmp_priv_passphrase`=VALUES(`snmp_priv_passphrase`), `snmp_priv_protocol`=VALUES(`snmp_priv_protocol`), `snmp_context`=VALUES(`snmp_context`), `snmp_engine_id`=VALUES(`snmp_engine_id`), `snmp_port`=VALUES(`snmp_port`), `snmp_timeout`=VALUES(`snmp_timeout`), `disabled`=VALUES(`disabled`), `availability_method`=VALUES(`availability_method`), `ping_method`=VALUES(`ping_method`), `ping_port`=VALUES(`ping_port`), `ping_timeout`=VALUES(`ping_timeout`), `ping_retries`=VALUES(`ping_retries`), `max_oids`=VALUES(`max_oids`), `device_threads`=VALUES(`device_threads`), `monitor`=VALUES(`monitor`), `monitor_text`=VALUES(`monitor_text`), `monitor_criticality`=VALUES(`monitor_criticality`), `monitor_warn`=VALUES(`monitor_warn`), `monitor_alert`=VALUES(`monitor_alert`), `thold_send_email`=VALUES(`thold_send_email`), `thold_host_email`=VALUES(`thold_host_email`)'
2017-03-13 10:37:50 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 53 form_save)(/host.php: 171 api_device_save)(/lib/api_device.php: 193 sql_save)(/lib/database.php: 920 CactiErrorHandler)(/lib/functions.php: 4265 cacti_debug_backtrace)
2017-03-13 10:37:50 - ERROR PHP NOTICE: Undefined index: external_id in file: /cacti/lib/database.php on line: 920
2017-03-13 10:37:50 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 53 form_save)(/host.php: 171 api_device_save)(/lib/api_device.php: 193 sql_save)(/lib/database.php: 919 CactiErrorHandler)(/lib/functions.php: 4265 cacti_debug_backtrace)
2017-03-13 10:37:50 - ERROR PHP NOTICE: Undefined index: external_id in file: /cacti/lib/database.php on line: 919
2017-03-13 10:37:50 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 53 form_save)(/host.php: 171 api_device_save)(/lib/api_device.php: 193 sql_save)(/lib/database.php: 918 CactiErrorHandler)(/lib/functions.php: 4265 cacti_debug_backtrace)
2017-03-13 10:37:50 - ERROR PHP NOTICE: Undefined index: external_id in file: /cacti/lib/database.php on line: 918
2017-03-13 10:37:50 - CMDPHP PHP ERROR NOTICE Backtrace: (/host.php: 53 form_save)(/host.php: 171 api_device_save)(/lib/api_device.php: 193 sql_save)(/lib/database.php: 917 CactiErrorHandler)(/lib/functions.php: 4265 cacti_debug_backtrace)
2017-03-13 10:37:50 - ERROR PHP NOTICE: Undefined index: external_id in file: /cacti/lib/database.php on line: 917
cigamit commented 7 years ago

Please manually run the database update. I'm guessing you were running on the development version and therefore, this change was missed.

dsclassen commented 7 years ago

OK. I tried to re-trigger an update from 1_0_5 by loading the following file in my browser.

<?php
include('include/global.php');
db_execute("UPDATE version SET  cacti = '1_0_5'");
Header("Location: index.php\n\n");

It goes through the first few stages of the upgrade, but gets stuck and I get this error:

Error
Invalid Cacti version 1_0_5, cannot upgrade to 1.0.6
cigamit commented 7 years ago

How about 1.0.5

dsclassen commented 7 years ago

Hmm. Well I feel stupid. It works with 1.0.5 but not 1_0_5 I swear this worked with underscores at some point. Anyways, it's working now. Thanks.