From 4105f15dd8c89341f49a8583590f9288a601bf47 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Wed, 15 Sep 2021 07:28:29 -0400 Subject: [PATCH] Correcting issues related to #4396 Moving this to a common function. We still need discussion on when it's best to perform table maintenance for tables like the `poller_output` table, that when this table is InnoDB, it can become fragmented, though empty and that free space can not be released without an optimize operation, which for InnoDB tables can take some time. --- poller.php | 62 +++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/poller.php b/poller.php index 341f28d88e..cc0d1a0317 100755 --- a/poller.php +++ b/poller.php @@ -194,35 +194,7 @@ function sig_handler($signo) { $overhead_time = 0; $current_time = time(); -// catch the unlikely event that the poller_output_boost is missing -if (!db_table_exists('poller_output_boost')) { - db_execute('CREATE TABLE poller_output_boost LIKE poller_output'); - db_execute('ALTER TABLE poller_output_boost ENGINE=InnoDB'); -} - -// catch the unlikely event that the poller_output_boost_processes is missing -if (!db_table_exists('poller_output_boost_processes')) { - db_execute('CREATE TABLE `poller_output_boost_processes` ( - `sock_int_value` bigint(20) unsigned NOT NULL auto_increment, - `status` varchar(255) default NULL, - PRIMARY KEY (`sock_int_value`)) - ENGINE=MEMORY'); -} - -// catch the unlikely event that the poller_output_realtime is missing -if (!db_table_exists('poller_output_realtime')) { - db_execute('CREATE TABLE poller_output_realtime ( - local_data_id mediumint(8) unsigned NOT NULL default '0', - rrd_name varchar(19) NOT NULL default '', - `time` timestamp NOT NULL default '0000-00-00 00:00:00', - output text NOT NULL, - poller_id varchar(256) NOT NULL default '1', - PRIMARY KEY (local_data_id, rrd_name, time, poller_id), - KEY poller_id (poller_id(191)), - KEY `time` (`time`)) - ENGINE=InnoDB - ROW_FORMAT=Dynamic'); -} +poller_table_maintenance(); api_plugin_hook('poller_top'); @@ -883,6 +855,38 @@ function bad_index_check($mibs) { } } +function poller_table_maintenance() { + // catch the unlikely event that the poller_output_boost is missing + if (!db_table_exists('poller_output_boost')) { + db_execute('CREATE TABLE poller_output_boost LIKE poller_output'); + db_execute('ALTER TABLE poller_output_boost ENGINE=InnoDB'); + } + + // catch the unlikely event that the poller_output_boost_processes is missing + if (!db_table_exists('poller_output_boost_processes')) { + db_execute('CREATE TABLE `poller_output_boost_processes` ( + `sock_int_value` bigint(20) unsigned NOT NULL auto_increment, + `status` varchar(255) default NULL, + PRIMARY KEY (`sock_int_value`)) + ENGINE=MEMORY'); + } + + // catch the unlikely event that the poller_output_realtime is missing + if (!db_table_exists('poller_output_realtime')) { + db_execute('CREATE TABLE poller_output_realtime ( + local_data_id int(10) unsigned NOT NULL default "0", + rrd_name varchar(19) NOT NULL default "", + `time` timestamp NOT NULL default "0000-00-00 00:00:00", + output text NOT NULL, + poller_id varchar(256) NOT NULL default "1", + PRIMARY KEY (local_data_id, rrd_name, time, poller_id), + KEY poller_id (poller_id), + KEY `time` (`time`)) + ENGINE=InnoDB + ROW_FORMAT=Dynamic'); + } +} + function poller_replicate_check() { global $config; include_once($config['base_path'] . '/lib/poller.php');