From 515516a07b1ecc291b86da9931bd3109842634b3 Mon Sep 17 00:00:00 2001 From: BerndP <32120318+bernisys@users.noreply.github.com> Date: Wed, 18 Sep 2024 10:16:21 +0200 Subject: [PATCH] Add logging to poller_boost.php --- poller_boost.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/poller_boost.php b/poller_boost.php index 4ccbb1d018..fb62ca7ada 100755 --- a/poller_boost.php +++ b/poller_boost.php @@ -163,6 +163,7 @@ */ $poller_items = db_fetch_row('SELECT * FROM poller_output_boost LIMIT 1'); if (!cacti_sizeof($poller_items)) { + cacti_log('INFO: Boost has no items in poller_output_boost to process during this cycle.', false, 'BOOST'); exit(0); } @@ -180,13 +181,18 @@ db_execute('TRUNCATE TABLE poller_output_boost_processes'); /* Prepare the boost distribution */ + cacti_log('INFO: Boost preparing tables ...', false, 'BOOST'); + $time_start = time(); $continue = boost_prepare_process_table(); + $time_end = time(); + cacti_log('INFO: Boost prepare tables took ' . ($time_end - $time_start) . 'seconds.', false, 'BOOST'); /* Launch the boost children */ if ($continue) { /* Allow mysql to flush the rename transaction */ sleep(7); + cacti_log('INFO: Boost spawning child processes ...', false, 'BOOST'); boost_launch_children(); /* Wait for all processes to continue */ @@ -195,6 +201,8 @@ sleep(2); } + cacti_log('INFO: Boost last child processes ended.', false, 'BOOST'); + /* tell the main poller that we are done */ set_config_option('boost_poller_status', 'complete - end time:' . date('Y-m-d H:i:s')); @@ -215,6 +223,7 @@ } if ($rrd_updates > 0) { + cacti_log('INFO: Boost removing archive tables ...', false, 'BOOST'); /* cleanup - remove empty arch tables*/ $tables = db_fetch_assoc("SELECT table_name AS name FROM information_schema.tables @@ -223,6 +232,7 @@ if (cacti_sizeof($tables)) { foreach($tables as $table) { + cacti_log('INFO: Boost removing archive table: ' . $table['name'], false, 'BOOST'); db_execute('DROP TABLE IF EXISTS ' . $table['name']); } } @@ -234,6 +244,7 @@ } } + cacti_log('INFO: Boost unregistering master process', false, 'BOOST'); unregister_process('boost', 'master', $config['poller_id'], getmypid()); /* log the end time of the process */ @@ -255,6 +266,7 @@ exit(0); } else { + cacti_log('INFO: Boost register child process ' . $child, false, 'BOOST'); /* we will warn if the process is taking extra long */ if (!register_process_start('boost', 'child', $child, read_config_option('boost_rrd_update_max_runtime') * 3)) { exit(0); @@ -375,9 +387,11 @@ function boost_prepare_process_table() { $archive_table = 'poller_output_boost_arch_' . $time; $interim_table = 'poller_output_boost_' . $time; + cacti_log('INFO: Boost rotating poller_output_boost into archive table: ' . $archive_table, false, 'BOOST'); db_execute("CREATE TABLE $interim_table LIKE poller_output_boost"); db_execute("RENAME TABLE poller_output_boost TO $archive_table, $interim_table TO poller_output_boost"); db_execute("ANALYZE TABLE $archive_table"); + cacti_log('INFO: Boost done rotating poller_output_boost', false, 'BOOST'); $arch_tables = boost_get_arch_table_names($archive_table); @@ -389,12 +403,15 @@ function boost_prepare_process_table() { $total_rows = 0; + cacti_log('INFO: Boost counting entries in archive tables ...', false, 'BOOST'); foreach($arch_tables as $table) { - $total_rows += db_fetch_cell_prepared('SELECT TABLE_ROWS + $table_rows = db_fetch_cell_prepared('SELECT TABLE_ROWS FROM information_schema.TABLES WHERE TABLE_SCHEMA = SCHEMA() AND TABLE_NAME = ?', array($table)); + $total_rows += $table_rows; + cacti_log('INFO: Boost archive table ' . $table . ' has ' . $table_rows . ' entries.', false, 'BOOST'); } if ($total_rows == 0) { @@ -403,6 +420,8 @@ function boost_prepare_process_table() { cacti_log('ERROR: Failed to retrieve any rows from archive tables', false, 'BOOST'); return false; + } else { + cacti_log('INFO: Boost processing a total of ' . $total_rows . ' entries.', false, 'BOOST'); } db_execute('CREATE TABLE IF NOT EXISTS poller_output_boost_local_data_ids (