@@ -2305,6 +2305,10 @@ sub run_command {
23052305 if ($arg -> {dbnumber } and $arg -> {dbnumber } != $num ) {
23062306 next ;
23072307 }
2308+ # # Likewise if we have specified "target" database info and this is not our choice
2309+ if ($arg -> {target } and $arg -> {target } != $db ) {
2310+ next ;
2311+ }
23082312
23092313 # # Just to keep things clean:
23102314 truncate $tempfh , 0;
@@ -7342,30 +7346,34 @@ sub check_sequence {
73427346FROM $seqname ) foo
73437347} ;
73447348 }
7345- my $seqinfo = run_command(join (" \n UNION ALL\n " , @seq_sql ), { target => $db }); # execute all SQL commands at once
7346- for my $r2 (@{$seqinfo -> {db }[0]{slurp }}) { # now look at all results
7347- my ($seqname , $last , $slots , $used , $percent , $left ) = @$r2 {qw/ seqname last_value slots used percent numleft / };
7348- if (! defined $last ) {
7349- ndie msg(' seq-die' , $seqname );
7350- }
7351- my $msg = msg(' seq-msg' , $seqname , $percent , $left );
7352- my $nicename = perfname(" $multidb$seqname " );
7353- $seqperf {$percent }{$seqname } = [$left , " $nicename =$percent %;$w %;$c %" ];
7354- if ($percent >= $maxp ) {
7355- $maxp = $percent ;
7356- if (! exists $opt {perflimit } or $limit ++ < $opt {perflimit }) {
7357- push @{$seqinfo {$percent }} => $MRTG ? [$seqname ,$percent ,$slots ,$used ,$left ] : $msg ;
7349+ # Use UNION ALL to query multiple sequences at once, however if there are too many sequences this can exceed
7350+ # maximum argument length; so split into chunks of 200 sequences or less and iterate over them.
7351+ while (my @seq_sql_chunk = splice @seq_sql , 0, 200) {
7352+ my $seqinfo = run_command(join (" \n UNION ALL\n " , @seq_sql_chunk ), { target => $db }); # execute all SQL commands at once
7353+ for my $r2 (@{$seqinfo -> {db }[0]{slurp }}) { # now look at all results
7354+ my ($seqname , $last , $slots , $used , $percent , $left ) = @$r2 {qw/ seqname last_value slots used percent numleft / };
7355+ if (! defined $last ) {
7356+ ndie msg(' seq-die' , $seqname );
73587357 }
7359- }
7360- next if $MRTG ;
7358+ my $msg = msg(' seq-msg' , $seqname , $percent , $left );
7359+ my $nicename = perfname(" $multidb$seqname " );
7360+ $seqperf {$percent }{$seqname } = [$left , " $nicename =$percent %;$w %;$c %" ];
7361+ if ($percent >= $maxp ) {
7362+ $maxp = $percent ;
7363+ if (! exists $opt {perflimit } or $limit ++ < $opt {perflimit }) {
7364+ push @{$seqinfo {$percent }} => $MRTG ? [$seqname ,$percent ,$slots ,$used ,$left ] : $msg ;
7365+ }
7366+ }
7367+ next if $MRTG ;
73617368
7362- if (length $critical and $percent >= $c ) {
7363- push @crit => $msg ;
7364- }
7365- elsif (length $warning and $percent >= $w ) {
7366- push @warn => $msg ;
7369+ if (length $critical and $percent >= $c ) {
7370+ push @crit => $msg ;
7371+ }
7372+ elsif (length $warning and $percent >= $w ) {
7373+ push @warn => $msg ;
7374+ }
73677375 }
7368- }
7376+ }
73697377 if ($MRTG ) {
73707378 my $msg = join ' | ' => map { $_ -> [0] } @{$seqinfo {$maxp }};
73717379 do_mrtg({one => $maxp , msg => $msg });
@@ -8009,8 +8017,6 @@ sub check_wal_files {
80098017
80108018} # # end of check_wal_files
80118019
8012-
8013-
80148020=pod
80158021
80168022=encoding utf8
0 commit comments