Skip to content

Commit 0477e93

Browse files
committed
Alert missing range partitioned Tables in part_config
1 parent 08bc046 commit 0477e93

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

check_postgres.pl

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ package check_postgres;
204204
'opt-psql-restrict' => q{Cannot use the --PGBINDIR or --PSQL option when NO_PSQL_OPTION is on},
205205
'partman-premake-ok' => q{All premade partitions are present},
206206
'partman-conf-tbl' => q{misconfigured in partman.part_config},
207+
'partman-conf-mis' => q{missing table in partman.part_config},
207208
'pgagent-jobs-ok' => q{No failed jobs},
208209
'pgbouncer-pool' => q{Pool=$1 $2=$3},
209210
'pgb-backends-mrtg' => q{DB=$1 Max connections=$2},
@@ -6546,7 +6547,46 @@ sub check_partman_premake {
65466547
default_critical => '3',
65476548
});
65486549

6550+
# check missing Config for range partitioned tables
6551+
65496552
my $SQL = q{
6553+
SELECT
6554+
current_database() AS database,
6555+
c.relnamespace::regnamespace || '.' || c.relname AS parent_table
6556+
FROM
6557+
pg_class c
6558+
JOIN pg_partitioned_table t ON t.partrelid = c.oid
6559+
WHERE
6560+
c.relkind = 'p'
6561+
AND t.partstrat = 'r'
6562+
AND NOT EXISTS (
6563+
SELECT
6564+
1
6565+
FROM
6566+
partman.part_config
6567+
WHERE
6568+
parent_table = c.relnamespace::regnamespace || '.' || c.relname);
6569+
};
6570+
6571+
my $info = run_command($SQL, {regex => qr[\w+], emptyok => 1 } );
6572+
my (@crit,@warn,@ok);
6573+
6574+
for $db (@{$info->{db}}) {
6575+
my ($maxage,$maxdb) = (0,''); ## used by MRTG only
6576+
ROW: for my $r (@{$db->{slurp}}) {
6577+
my ($dbname,$parent_table) = ($r->{database},$r->{parent_table});
6578+
$found = 1 if ! $found;
6579+
next ROW if skip_item($dbname);
6580+
$found = 2;
6581+
6582+
$msg = "$dbname=$parent_table " . msg('partman-conf-mis');
6583+
push @crit => $msg;
6584+
};
6585+
};
6586+
6587+
# check Config Errors
6588+
6589+
$SQL = q{
65506590
SELECT
65516591
current_database() as database,
65526592
parent_table
@@ -6562,8 +6602,7 @@ sub check_partman_premake {
65626602
configured_partitions < 1;
65636603
};
65646604

6565-
my $info = run_command($SQL, {regex => qr[\w+], emptyok => 1 } );
6566-
my (@crit,@warn,@ok);
6605+
$info = run_command($SQL, {regex => qr[\w+], emptyok => 1 } );
65676606

65686607
for $db (@{$info->{db}}) {
65696608
my ($maxage,$maxdb) = (0,''); ## used by MRTG only

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy