@@ -2254,6 +2254,10 @@ sub run_command {
2254
2254
if ($arg -> {dbnumber } and $arg -> {dbnumber } != $num ) {
2255
2255
next ;
2256
2256
}
2257
+ # # Likewise if we have specified "target" database info and this is not our choice
2258
+ if ($arg -> {target } and $arg -> {target } != $db ) {
2259
+ next ;
2260
+ }
2257
2261
2258
2262
# # Just to keep things clean:
2259
2263
truncate $tempfh , 0;
@@ -7291,30 +7295,34 @@ sub check_sequence {
7291
7295
FROM $seqname ) foo
7292
7296
} ;
7293
7297
}
7294
- my $seqinfo = run_command(join (" \n UNION ALL\n " , @seq_sql ), { target => $db }); # execute all SQL commands at once
7295
- for my $r2 (@{$seqinfo -> {db }[0]{slurp }}) { # now look at all results
7296
- my ($seqname , $last , $slots , $used , $percent , $left ) = @$r2 {qw/ seqname last_value slots used percent numleft / };
7297
- if (! defined $last ) {
7298
- ndie msg(' seq-die' , $seqname );
7299
- }
7300
- my $msg = msg(' seq-msg' , $seqname , $percent , $left );
7301
- my $nicename = perfname(" $multidb$seqname " );
7302
- $seqperf {$percent }{$seqname } = [$left , " $nicename =$percent %;$w %;$c %" ];
7303
- if ($percent >= $maxp ) {
7304
- $maxp = $percent ;
7305
- if (! exists $opt {perflimit } or $limit ++ < $opt {perflimit }) {
7306
- push @{$seqinfo {$percent }} => $MRTG ? [$seqname ,$percent ,$slots ,$used ,$left ] : $msg ;
7298
+ # Use UNION ALL to query multiple sequences at once, however if there are too many sequences this can exceed
7299
+ # maximum argument length; so split into chunks of 200 sequences or less and iterate over them.
7300
+ while (my @seq_sql_chunk = splice @seq_sql , 0, 200) {
7301
+ my $seqinfo = run_command(join (" \n UNION ALL\n " , @seq_sql_chunk ), { target => $db }); # execute all SQL commands at once
7302
+ for my $r2 (@{$seqinfo -> {db }[0]{slurp }}) { # now look at all results
7303
+ my ($seqname , $last , $slots , $used , $percent , $left ) = @$r2 {qw/ seqname last_value slots used percent numleft / };
7304
+ if (! defined $last ) {
7305
+ ndie msg(' seq-die' , $seqname );
7307
7306
}
7308
- }
7309
- next if $MRTG ;
7307
+ my $msg = msg(' seq-msg' , $seqname , $percent , $left );
7308
+ my $nicename = perfname(" $multidb$seqname " );
7309
+ $seqperf {$percent }{$seqname } = [$left , " $nicename =$percent %;$w %;$c %" ];
7310
+ if ($percent >= $maxp ) {
7311
+ $maxp = $percent ;
7312
+ if (! exists $opt {perflimit } or $limit ++ < $opt {perflimit }) {
7313
+ push @{$seqinfo {$percent }} => $MRTG ? [$seqname ,$percent ,$slots ,$used ,$left ] : $msg ;
7314
+ }
7315
+ }
7316
+ next if $MRTG ;
7310
7317
7311
- if (length $critical and $percent >= $c ) {
7312
- push @crit => $msg ;
7313
- }
7314
- elsif (length $warning and $percent >= $w ) {
7315
- push @warn => $msg ;
7318
+ if (length $critical and $percent >= $c ) {
7319
+ push @crit => $msg ;
7320
+ }
7321
+ elsif (length $warning and $percent >= $w ) {
7322
+ push @warn => $msg ;
7323
+ }
7316
7324
}
7317
- }
7325
+ }
7318
7326
if ($MRTG ) {
7319
7327
my $msg = join ' | ' => map { $_ -> [0] } @{$seqinfo {$maxp }};
7320
7328
do_mrtg({one => $maxp , msg => $msg });
@@ -7958,8 +7966,6 @@ sub check_wal_files {
7958
7966
7959
7967
} # # end of check_wal_files
7960
7968
7961
-
7962
-
7963
7969
=pod
7964
7970
7965
7971
=encoding utf8
0 commit comments