From c8055ae803f63a6300c79c8ad0319d92a8c3bcb1 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Mon, 5 Aug 2024 16:40:47 +0200 Subject: [PATCH] fix(gorgone/mbi): add weekly and monthly centiles partitioning (#1546) Co-authored-by: Colin Gagnaire --- .../modules/centreon/mbi/etl/perfdata/main.pm | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gorgone/gorgone/modules/centreon/mbi/etl/perfdata/main.pm b/gorgone/gorgone/modules/centreon/mbi/etl/perfdata/main.pm index 0a8c74ac47c..352ef950c9d 100644 --- a/gorgone/gorgone/modules/centreon/mbi/etl/perfdata/main.pm +++ b/gorgone/gorgone/modules/centreon/mbi/etl/perfdata/main.pm @@ -346,6 +346,30 @@ sub dailyProcessing { ] }; } + if (defined($etl->{run}->{etlProperties}->{'centile.week'}) && $etl->{run}->{etlProperties}->{'centile.week'} eq '1') { + push @{$etl->{run}->{schedule}->{perfdata}->{stages}->[0]}, { + type => 'sql', + db => 'centstorage', + sql => [ + [ + '[PARTITIONS] Add partition [p' . $partName . '] on table [mod_bi_metriccentileweeklyvalue]', + "ALTER TABLE `mod_bi_metriccentileweeklyvalue` ADD PARTITION (PARTITION `p$partName` VALUES LESS THAN(" . $epoch . "))" + ] + ] + }; + } + if (defined($etl->{run}->{etlProperties}->{'centile.month'}) && $etl->{run}->{etlProperties}->{'centile.month'} eq '1') { + push @{$etl->{run}->{schedule}->{perfdata}->{stages}->[0]}, { + type => 'sql', + db => 'centstorage', + sql => [ + [ + '[PARTITIONS] Add partition [p' . $partName . '] on table [mod_bi_metriccentilemonthlyvalue]', + "ALTER TABLE `mod_bi_metriccentilemonthlyvalue` ADD PARTITION (PARTITION `p$partName` VALUES LESS THAN(" . $epoch . "))" + ] + ] + }; + } # processing agregation by month. If the day is the first day of the month, also processing agregation by month processDayAndMonthAgregation($etl, $liveServices, $start, $end);