Skip to content

Commit

Permalink
Fixed: more fix for #5336 for boost enabled (#5645)
Browse files Browse the repository at this point in the history
* Fixed: more fix for #5336 for boost enabled

* Update CHANGELOG for PR#5645
  • Loading branch information
ddb4github authored and TheWitness committed Jan 29, 2024
1 parent fbd1b4b commit 4efa477
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Cacti CHANGELOG
-issue#5622: Errors and deprecation warnings with PHP 8.3.0
-issue#5629: auth_changepassword.php cannot return to the refer url by just clicking the "Return" button once
-issue#5638: Add tooltip info about IPv6 address
-issue#5645: Boost poller fail to update rrd which Data Template and Graph Template items do not match
-issue#5648: Fractional time offsets can cause huge webserver error-logs
-issue#5649: Inapprorpiate use of PHP_OS in lib/ping.php on Windows Platform
-issue#5655: Function get_allowed_devices can returns incorrect device list if session user_id variable is not set
Expand Down
15 changes: 15 additions & 0 deletions lib/boost.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,10 +863,25 @@ function boost_process_poller_output($local_data_id, $rrdtool_pipe = null) {
cacti_log('The RRDpath is ' . $rrd_path, false, 'BOOST', POLLER_VERBOSITY_MEDIUM);
cacti_log('The RRDpath template is ' . $rrd_tmpl, false, 'BOOST', POLLER_VERBOSITY_MEDIUM);

$unused_data_source_names = array_rekey(
db_fetch_assoc_prepared('SELECT DISTINCT dtr.data_source_name, dtr.data_source_name
FROM data_template_rrd AS dtr
LEFT JOIN graph_templates_item AS gti
ON dtr.id = gti.task_item_id
WHERE dtr.local_data_id = ?
AND gti.task_item_id IS NULL',
array($local_data_id)),
'data_source_name', 'data_source_name'
);

boost_timer('results_cycle', BOOST_TIMER_START);

/* go through each poller_output_boost entries and process */
foreach ($results as $item) {
if (cacti_sizeof($unused_data_source_names) && isset($unused_data_source_names[$item['rrd_name']])) {
continue;
}

/**
* detect duplicate records, this should not happen,
* but adding just in case.
Expand Down
20 changes: 20 additions & 0 deletions poller_boost.php
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,19 @@ function boost_process_local_data_ids($last_id, $child, $rrdtool_pipe) {
$last_update = -1;
$reset_template = true;

$unused_data_source_names = array();

/* we are going to blow away all record if ok */
$vals_in_buffer = 0;

boost_timer('results_cycle', BOOST_TIMER_START);

/* go through each poller_output_boost entries and process */
foreach ($results as $item) {
if ($local_data_id == $item['local_data_id'] && cacti_sizeof($unused_data_source_names) && isset($unused_data_source_names[$item['rrd_name']])) {
continue;
}

$item['timestamp'] = trim($item['timestamp']);

if (!$locked) {
Expand All @@ -803,6 +809,20 @@ function boost_process_local_data_ids($last_id, $child, $rrdtool_pipe) {
* and discover the template for the next RRDfile.
*/
if ($local_data_id != $item['local_data_id']) {
$unused_data_source_names = array_rekey(
db_fetch_assoc_prepared('SELECT DISTINCT dtr.data_source_name, dtr.data_source_name
FROM data_template_rrd AS dtr
LEFT JOIN graph_templates_item AS gti
ON dtr.id = gti.task_item_id
WHERE dtr.local_data_id = ?
AND gti.task_item_id IS NULL',
array($item['local_data_id'])),
'data_source_name', 'data_source_name'
);
if (cacti_sizeof($unused_data_source_names) && isset($unused_data_source_names[$item['rrd_name']])) {
continue;
}

$reset_template = true;

if (isset($nt_rrd_field_names)) {
Expand Down

0 comments on commit 4efa477

Please sign in to comment.