Skip to content

Commit

Permalink
QA: Properly process archive removal
Browse files Browse the repository at this point in the history
* Previous method was generating errors.
  • Loading branch information
TheWitness committed Sep 28, 2024
1 parent 5c9d468 commit 71df174
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions poller_dsstats.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,20 @@ function dsstats_remove_old_partitions($current_time, $fpartition = false) {
}

function dsstats_prune_partitions($table_name, $partitions_to_keep) {
$tables = db_fetch_assoc("SHOW TABLES LIKE '{$table_name}_v%'");
global $database_default;

$tables = db_fetch_assoc_prepared("SELECT TABLE_NAME
FROM information_schema.TABLES
WHERE TABLE_NAME LIKE '{$table_name}_v%' AND TABLE_SCHEMA = ?",
array($database_default));

if (cacti_sizeof($tables) > $partitions_to_keep) {
$partitions_to_delete = cacti_sizeof($tables) - $partitions_to_keep;

$partitions = array();

foreach($tables as $table) {
$tname = $table[0];
$tname = $table['TABLE_NAME'];
$parts = explode('_v', $tname);
$partitions[] = $parts[1];
}
Expand Down

0 comments on commit 71df174

Please sign in to comment.