Skip to content

Commit c63e83a

Browse files
committed
detect gaps in premade partitions
1 parent 40cbd04 commit c63e83a

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

check_postgres.pl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6787,7 +6787,8 @@ sub check_partman_premake {
67876787
};
67886788
};
67896789

6790-
6790+
# the highest partition boundarie must not be lower than the configured premake
6791+
# if the highest partition boundarie is higher than the configured premake, this is a gap indicator
67916792
$SQL = q{
67926793
SELECT
67936794
current_database() as database,
@@ -6818,7 +6819,11 @@ sub check_partman_premake {
68186819
ON
68196820
a.parent_table::text = b.parent_table::text
68206821
WHERE
6821-
b.date - a.date::date > 0
6822+
-- the highest partition boundarie must not be lower than the configured premake
6823+
b.date > a.date::date
6824+
OR
6825+
-- if the highest partition boundarie is higher than the configured premake, this is a gap indicator
6826+
a.date::date - b.date > 100
68226827
ORDER BY 3, 2 DESC
68236828
};
68246829

@@ -6832,14 +6837,19 @@ sub check_partman_premake {
68326837
next ROW if skip_item($dbname);
68336838
$found = 2;
68346839

6835-
$msg = "$dbname=$parent_table ($missing_days)";
6836-
print "$msg";
6840+
if ( $missing_days < 0 ){
6841+
$msg = "$dbname=$parent_table ($missing_days) gap ";
6842+
6843+
} else {
6844+
$msg = "$dbname=$parent_table ($missing_days) missing days ";
6845+
}
6846+
#print "$msg";
68376847
$db->{perf} .= sprintf ' %s=%sd;%s;%s',
68386848
perfname($dbname), $missing_days, $warning, $critical;
6839-
if (length $critical and $missing_days >= $critical) {
6849+
if (length $critical and abs($missing_days) >= $critical) {
68406850
push @crit => $msg;
68416851
}
6842-
elsif (length $warning and $missing_days >= $warning) {
6852+
elsif (length $warning and abs($missing_days) >= $warning) {
68436853
push @warn => $msg;
68446854
}
68456855
else {

0 commit comments

Comments
 (0)