use 5.006001;
use strict;
use warnings;
+use utf8;
use Getopt::Long qw/GetOptions/;
Getopt::Long::Configure(qw/no_ignore_case/);
use File::Basename qw/basename/;
our %msg = (
'en' => {
- 'T-EXCLUDE-DB' => q{No matching databases found due to exclusion/inclusion options},
- 'T-EXCLUDE-FS' => q{No matching file systems found due to exclusion/inclusion options},
- 'T-EXCLUDE-REL' => q{No matching relations found due to exclusion/inclusion options},
- 'T-EXCLUDE-SET' => q{No matching settings found due to exclusion/inclusion options},
- 'T-EXCLUDE-TABLE' => q{No matching tables found due to exclusion/inclusion options},
- 'T-EXCLUDE-USEROK' => q{No matching entries found due to user exclusion/inclusion options},
- 'T-BAD-QUERY' => q{Invalid query returned:},
+ 'no-match-db' => q{No matching databases found due to exclusion/inclusion options},
+ 'no-match-fs' => q{No matching file systems found due to exclusion/inclusion options},
+ 'no-match-rel' => q{No matching relations found due to exclusion/inclusion options},
+ 'no-match-set' => q{No matching settings found due to exclusion/inclusion options},
+ 'no-match-table' => q{No matching tables found due to exclusion/inclusion options},
+ 'no-match-user' => q{No matching entries found due to user exclusion/inclusion options},
+ 'invalid-query' => q{Invalid query returned: $1},
'invalid-psql' => q{Invalid psql argument: must be full path to a file named psql},
'no-find-psql' => q{Cannot find given psql executable: $1},
'no-time-hires' => q{Cannot find Time::HiRes, needed if 'showtime' is true},
'symlink-fail' => qq{Could not symlink \$1 to \$2: \$3\n},
'no-target-database' => q{No target databases could be found},
'psql-no-opt' => q{Cannot use the --PSQL option when NO_PSQL_OPTION is on},
-},
-'de' => {
- 'T-BAD-QUERY' => q{Invalid query returned:},
-},
-'es' => {
- 'T-BAD-QUERY' => q{Invalid query returned:},
+ 'minimum-bloat' => q{no relations meet the minimum bloat criteria},
+ 'bloat-table' => q{table $1.$2 rows:$3 pages:$3 shouldbe:$4 ($5X) wasted size:$6 ($7)},
+ 'bloat-index' => q{index $1 rows:$2 pages:$3 shouldbe:$4 ($5X) wasted bytes:$6 ($7)},
+ 'unknown-error' => q{unknown error},
},
'fr' => {
- 'T-EXCLUDE-DB' => q{Aucune base de données trouvée à cause des options d'exclusion/inclusion},
- 'T-EXCLUDE-FS' => q{Aucun système de fichier trouvé à cause des options d'exclusion/inclusion},
- 'T-EXCLUDE-REL' => q{Aucune relation trouvée à cause des options d'exclusion/inclusion},
- 'T-EXCLUDE-SET' => q{Aucun paramètre trouvé à cause des options d'exclusion/inclusion},
- 'T-EXCLUDE-TABLE' => q{Aucune table trouvée à cause des options d'exclusion/inclusion},
- 'T-EXCLUDE-USEROK' => q{Aucune entrée trouvée à cause options d'exclusion/inclusion},
- 'T-BAD-QUERY' => q{Une requête invalide a renvoyé :},
+ 'no-match-db' => q{Aucune base de données trouvée à cause des options d'exclusion/inclusion},
+ 'no-match-fs' => q{Aucun système de fichier trouvé à cause des options d'exclusion/inclusion},
+ 'no-match-rel' => q{Aucune relation trouvée à cause des options d'exclusion/inclusion},
+ 'no-match-set' => q{Aucun paramètre trouvé à cause des options d'exclusion/inclusion},
+ 'no-match-table' => q{Aucune table trouvée à cause des options d'exclusion/inclusion},
+ 'no-match-user' => q{Aucune entrée trouvée à cause options d'exclusion/inclusion},
+ 'invalid-query' => q{Une requête invalide a renvoyé : $1},
'invalid-psql' => q{Argument psql invalide : doit correspondre au chemin complet vers le fichier nommé psql},
'no-find-psql' => q{N'a pas pu trouver l'exécutable psql : $1},
'no-time-hires' => q{N'a pas trouvé le module Time::HiRes, nécessaire quand 'showtime' est activé},
'symlink-fail' => qq{N'a pas pu supprimer le lien symbolique \$1 vers \$2 : \$3\n},
'no-target-database' => q{Aucune base de données cible trouvée},
},
+'de' => {
+ 'invalid-query' => q{Invalid query returned: $1},
+},
+'es' => {
+ 'invalid-query' => q{Invalid query returned: $1},
+},
);
my $lang = $ENV{LC_ALL} || $ENV{LC_MESSAGES} || $ENV{LANG} || 'en';
## Check if problem is due to backend being too old for this check
verify_version();
- add_unknown qq{T-BAD-QUERY $db->{slurp}};
+ add_unknown msg('invalid-query', $db->{slurp});
## Remove it from the returned hash
pop @{$info->{db}};
}
next;
}
if (!$total) {
- add_unknown 'T-EXCLUDE-DB';
+ add_unknown msg('no-match-db');
next;
}
my $percent = (int $total / $limit*100) || 1;
my %seenit;
for $db (@{$info->{db}}) {
if ($db->{slurp} !~ /\w+\s+\|/o) {
- add_ok q{no relations meet the minimum bloat criteria} unless $MRTG;
+ add_ok msg('minimum-bloat') unless $MRTG;
next;
}
## Not a 'regex' to run_command as we need to check the above first.
if ($db->{slurp} !~ /\d+\s*\| \d+/) {
- add_unknown qq{T-BAD-QUERY $db->{slurp}} unless $MRTG;
+ add_unknown msg('invalid-query', $db->{slurp}) unless $MRTG;
next;
}
## Do the table first if we haven't seen it
if (! $seenit{"$schema.$table"}++) {
$db->{perf} .= " $schema.$table=$wb";
- my $msg = qq{table $schema.$table rows:$tups pages:$pages shouldbe:$otta (${bloat}X)};
- $msg .= qq{ wasted size:$wb ($ws)};
+ my $msg = msg('bloat-table', $schema, $table, $tups, $pages, $otta, $bloat, $wb, $ws);
my $ok = 1;
my $perbloat = $bloat * 100;
## Now the index, if it exists
if ($index ne '?') {
$db->{perf} .= " $index=$iwb" if $iwb;
- my $msg = qq{index $index rows:$irows pages:$ipages shouldbe:$iotta (${ibloat}X)};
- $msg .= qq{ wasted bytes:$iwb ($iws)};
+ my $msg = msg('bloat-index', $index, $irows, $ipages, $iotta, $ibloat, $iwb, $iws);
my $ok = 1;
my $iperbloat = $ibloat * 100;
}
}
if ($max == -1) {
- add_unknown 'T-EXCLUDE-REL';
+ add_unknown msg('no-match-rel');
}
elsif ($max != -1) {
add_ok $maxmsg;
}
if ($MRTG) {
- keys %stats or bad_mrtg('unknown error');
+ keys %stats or bad_mrtg(msg('unknown error'));
## We are going to report the highest wasted bytes for table and index
my ($one,$two,$msg) = ('','');
## Can also sort by ratio
## Parse it out and return our information
for $db (@{$info->{db}}) {
if ($db->{slurp} !~ /PostgreSQL (\S+)/o) { ## no critic (ProhibitUnusedCapture)
- add_unknown "T-BAD-QUERY $db->{slurp}";
+ add_unknown msg('invalid-query', $db->{slurp});
next;
}
add_ok "version $1";
}
if ($max < 0) {
if ($USERWHERECLAUSE) {
- add_ok 'T-EXCLUDE-USEROK';
+ add_ok msg('no-match-user');
}
else {
- add_unknown 'T-EXCLUDE-DB';
+ add_unknown msg('no-match-db');
}
next;
}
next if $MRTG;
if (!$gotone) {
- add_unknown 'T-EXCLUDE-FS';
+ add_unknown msg('no-match-fs');
}
}
my $found = 0;
for $db (@{$info->{db}}) {
if ($db->{slurp} !~ /(\d+)/) {
- add_unknown qq{T-BAD-QUERY $db->{slurp}};
+ add_unknown msg('invalid-query', $db->{slurp});
next;
}
$found = 1;
$found = 1;
if ($db->{slurp} !~ /\w/ and $USERWHERECLAUSE) {
- add_ok 'T-EXCLUDE-USEROK';
+ add_ok msg('no-match-user');
next;
}
if ($db->{slurp} !~ /\d+\s+\|\s+\d+/) {
- add_unknown "T-BAD-QUERY $db->{slurp}";
+ add_unknown msg('invalid-query', $db->{slurp});
next;
}
($max=$size, $pmax=$psize, $kmax=$kind, $nmax=$name, $smax=$schema) if $size > $max;
}
if ($max < 0) {
- add_unknown 'T-EXCLUDE-REL';
+ add_unknown msg('no-match-rel');
next;
}
if ($MRTG) {
for $db (@{$info->{db}}) {
if ($db->{slurp} !~ /\w/ and $USERWHERECLAUSE) {
- add_ok 'T-EXCLUDE-USEROK';
+ add_ok msg('no-match-user');
next;
}
next;
}
if ($maxtime == -2) {
- add_unknown 'T-EXCLUDE-TABLE';
+ add_unknown msg('no-match-table');
}
elsif ($maxtime == -1) {
add_unknown sprintf "No matching tables have ever been $type%s",
for $db (@{$info->{db}}) {
if ($db->{slurp} !~ /(\d+)/) {
- add_unknown "T-BAD_QUERY $db->{slurp}";
+ add_unknown msg('invalid-query', $db->{slurp});
next;
}
my $count = $1;
}
if (!$gotone) {
- add_unknown 'T-EXCLUDE-DB';
+ add_unknown msg('no-match-db');
}
## If not specific errors, just use the total
for $db (@{$info->{db}}) {
if ($db->{slurp} !~ /^\s*(\w+)\n\s*(.+?)\n\s*(.+?)\n\s*(\w*)\n\s*(\w*)/sm) {
- add_unknown "T-BAD-QUERY $db->{slurp}";
+ add_unknown msg('invalid-query', $db->{slurp});
next;
}
my ($dest,$dir,$file,$redirect,$facility) = ($1,$2,$3,$4,$5||'?');
for $db (@{$info->{db}}) {
if ($db->{slurp} !~ /Total runtime: (\d+\.\d+) ms\s*$/s) {
- add_unknown "T-BAD-QUERY $db->{slurp}";
+ add_unknown msg('invalid-query', $db->{slurp});
next;
}
my $totalseconds = $1 / 1000.0;
for $db (@{$info->{db}}) {
if ($db->{slurp} !~ /\w/ and $USERWHERECLAUSE) {
- add_ok 'T-EXCLUDE-USEROK';
+ add_ok msg('no-match-user');
next;
}
}
if ($db->{slurp} !~ /\w/ and $USERWHERECLAUSE) {
- add_ok 'T-EXCLUDE-USEROK';
+ add_ok msg('no-match-user');
next;
}
$found = 1;
my $max = -1;
if ($db->{slurp} !~ /\w/ and $USERWHERECLAUSE) {
- add_ok 'T-EXCLUDE-USEROK';
+ add_ok msg('no-match-user');
next;
}
$newstring .= "$line\n";
}
if (! length $newstring) {
- add_unknown 'T-EXCLUDE-SET';
+ add_unknown msg('no-match-set');
}
my $checksum = Digest::MD5::md5_hex($newstring);
for $db (@{$info->{db}}) {
if ($db->{slurp} !~ /(\d+) \| (.+)/) {
- add_unknown "T-BAD-QUERY $db->{slurp}";
+ add_unknown msg('invalid-query', $db->{slurp});
next;
}
my ($pgepoch,$pgpretty) = ($1,$2);
for $db (@{$info->{db}}) {
if ($db->{slurp} !~ /PostgreSQL ((\d+\.\d+)(\w+|\.\d+))/o) {
- add_unknown "T-BAD-QUERY $db->{slurp}";
- warn "FOO?\n";
+ add_unknown msg('invalid-query', $db->{slurp});
next;
}
my ($full,$version,$revision) = ($1,$2,$3||'?');