Skip to content

Commit

Permalink
Correcting issues related to #4396
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TheWitness committed Sep 15, 2021
1 parent 33506cd commit 4105f15
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions poller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 4105f15

Please sign in to comment.