From ea25a80b1e9d994aaefe2cfdee3ba9b7cd3cbd52 Mon Sep 17 00:00:00 2001 From: cigamit Date: Thu, 19 Sep 2019 07:08:52 -0500 Subject: [PATCH] Resolving Issue #2929 Boost performance decreased after updating to Cacti 1.2.6 --- CHANGELOG | 1 + lib/boost.php | 8 ++++++-- poller_boost.php | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 297e4d654..003e47dfe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ Cacti CHANGELOG -issue#2922: Undefined variable 'result' in lib/data_query.php -issue#2925: Problem with consolidation function after upgade to 1.2.6 -issue#2926: Cacti 1.2.6 failed to update graph +-issue#2929: Boost performance decreased after updating to Cacti 1.2.6 -issue#2930: When working in pipe mode RRDtool appends stderr to stdout causing SVG graphing to break -issue#2932: Some cases where RRDtool can not generate an image are not captured by Cactis image error logic -issue#2936: Installer will loop when number of tables exceeds PHP's max_input_vars limit diff --git a/lib/boost.php b/lib/boost.php index 54c6c390c..0236de86d 100644 --- a/lib/boost.php +++ b/lib/boost.php @@ -585,7 +585,7 @@ function boost_get_arch_table_name() { AND table_name LIKE 'poller_output_boost_arch_%'"); foreach($tables as $table) { - $rows = db_fetch_cell('SELECT count(*) FROM '.$table['name']); + $rows = db_fetch_cell('SELECT COUNT(local_data_id) FROM ' . $table['name']); if (is_numeric($rows) && intval($rows) > 0) { return $table['name']; } @@ -600,6 +600,7 @@ function boost_get_arch_table_name() { function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') { global $config, $database_default, $boost_sock, $boost_timeout, $debug, $get_memory, $memory_used; + static $archive_table = false; static $warning_issued; include_once($config['library_path'] . '/rrd.php'); @@ -627,7 +628,10 @@ function boost_process_poller_output($local_data_id = '', $rrdtool_pipe = '') { } else { $single_local_data_id = false; - $archive_table = boost_get_arch_table_name(); + if ($archive_table === false) { + $archive_table = boost_get_arch_table_name(); + } + if ($archive_table === false) { if ($warning_issued != true) { cacti_log('NOTE: Failed to determine archive table', false, 'BOOST', POLLER_VERBOSITY_MEDIUM); diff --git a/poller_boost.php b/poller_boost.php index 6e8d6fa04..a0533969c 100644 --- a/poller_boost.php +++ b/poller_boost.php @@ -361,6 +361,9 @@ function boost_process_local_data_ids($last_id) { global $config, $boost_sock, $boost_timeout, $debug, $get_memory, $memory_used; global $rrdtool_pipe, $rrdtool_read_pipe; + /* cache this call as it takes time */ + static $archive_table = false; + include_once($config['library_path'] . '/rrd.php'); /* suppress warnings */ @@ -380,7 +383,9 @@ function boost_process_local_data_ids($last_id) { $rrd_update_interval = read_config_option('boost_rrd_update_interval'); $data_ids_to_get = read_config_option('boost_rrd_update_max_records_per_select'); - $archive_table = boost_get_arch_table_name(); + if ($archive_table === false) { + $archive_table = boost_get_arch_table_name(); + } if ($archive_table === FALSE) { cacti_log('Failed to determine archive table', FALSE, 'BOOST');