Skip to content

Field 'last_time' doesn't have a default value #1

@choefing

Description

@choefing

Thanks for the effort to make this plugin work again until whatever final fix.

Plain Cacti 1.2.8 on Debian with MariaDB
Weathermap cloned from git here

I got messages in Cacti pointing to a not existing default value for "last_time".

12/27/2019 15:05:03 - CMDPHP ERRORS DETECTED - DISABLING PLUGIN 'weathermap'

12/27/2019 15:05:03 - CMDPHP PHP ERROR Backtrace: (CactiShutdownHandler())
12/27/2019 15:05:03 - ERROR PHP ERROR in Plugin 'weathermap': Uncaught PDOException: SQLSTATE[HY000]: General error: 1364 Field 'last_value' doesn't have a default value in /opt/cacti-1.2.8/plugins/weathermap/lib/datasources/WeatherMapDataSource_rrd.php:143 Stack trace: #0 /opt/cacti-1.2.8/plugins/weathermap/lib/datasources/WeatherMapDataSource_rrd.php(143): PDOStatement->execute(Array) #1 /opt/cacti-1.2.8/plugins/weathermap/lib/datasources/WeatherMapDataSource_rrd.php(596): WeatherMapDataSource_rrd->wmrrd_read_from_poller_output('/opt/cacti-1.2....', 'AVERAGE', 'now-800', 'now', Array, Array, Object(WeatherMap), 0, Object(WeatherMapLink)) #2 /opt/cacti-1.2.8/plugins/weathermap/lib/Weathermap.class.php(955): WeatherMapDataSource_rrd->ReadData('/opt/cacti-1.2....', Object(WeatherMap), Object(WeatherMapLink)) #3 /opt/cacti-1.2.8/plugins/weathermap/lib/poller-common.php(195): WeatherMap->ReadData() #4 /opt/cacti-1.2.8/plugins/weathermap/setup.php(778): weathermap_run_maps('/opt/cacti-1.2....') #5 /opt/cacti-1.2.8/lib/plugins.php(177): weathermap_poller_bottom(Array) #6 /op in file: /opt/cacti-1.2.8/plugins/weathermap/lib/datasources/WeatherMapDataSource_rrd.php on line: 143

I tried to fix that in setup.php where the line 370ff
if ( !in_array( 'weathermap_data', $tables ) ) { $sql[] = "CREATE TABLE IF NOT EXISTS weathermap_data (id int(11) NOT NULL auto_increment, rrdfile varchar(255) NOT NULL,data_source_name varchar(19) NOT NULL, last_time int(11) DEFAULT -1 NOT NULL,last_value varchar(255) DEFAULT '' NOT NULL, last_calc varchar(255) DEFAULT '' NOT NULL, sequence int(11) NOT NULL, local_data_id int(11) NOT NULL DEFAULT 0, PRIMARY KEY (id), KEY rrdfile (rrdfile), KEY local_data_id (local_data_id), KEY data_source_name (data_source_name) ) ENGINE=MyISAM";

But for me it seems an "uninstall plugin" does not drop the tables / revert the changes done by installing and a re-install also does not update them properly if existent.
Manually dropping the tables weathermap_* and re-adding them seem to not work properly too as there might be actions executed against other tables.

Not a PHP/SQL pro but hope that helps to figure out the issue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions