Skip to content

Commit ab94f2b

Browse files
committed
Perl::Critic based changes
1 parent b8d6030 commit ab94f2b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+154
-137
lines changed

META.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ distribution_type : script
1010
dynamic_config : 0
1111

1212
requires:
13-
perl : 5.006001
13+
perl : 5.008
1414
build_requires:
1515
Test::More : 0.61
1616
recommends:

Makefile.PL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use ExtUtils::MakeMaker qw/WriteMakefile/;
44
use Config;
55
use strict;
66
use warnings;
7-
use 5.006001;
7+
use 5.008;
88

99
my $VERSION = '2.25.0';
1010

check_postgres.pl

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package check_postgres;
1818

19-
use 5.006001;
19+
use 5.008;
2020
use strict;
2121
use warnings;
2222
use utf8;
@@ -2815,15 +2815,15 @@ sub pretty_time {
28152815

28162816
## Just seconds (< 2:00)
28172817
if ($sec < 120 or $tweak =~ /s/) {
2818-
return sprintf "$sec %s", $sec==1 ? msg('time-second') : msg('time-seconds');
2818+
return sprintf "$sec %s", 1==$sec ? msg('time-second') : msg('time-seconds');
28192819
}
28202820

28212821
## Minutes and seconds (< 60:00)
28222822
if ($sec < 60*60 or $tweak =~ /m/) {
28232823
my $min = int $sec / 60;
28242824
$sec %= 60;
2825-
my $ret = sprintf "$min %s", $min==1 ? msg('time-minute') : msg('time-minutes');
2826-
$sec and $tweak !~ /S/ and $ret .= sprintf " $sec %s", $sec==1 ? msg('time-second') : msg('time-seconds');
2825+
my $ret = sprintf "$min %s", 1==$min ? msg('time-minute') : msg('time-minutes');
2826+
$sec and $tweak !~ /S/ and $ret .= sprintf " $sec %s", 1==$sec ? msg('time-second') : msg('time-seconds');
28272827
return $ret;
28282828
}
28292829

@@ -2833,9 +2833,9 @@ sub pretty_time {
28332833
$sec -= ($hour*60*60);
28342834
my $min = int $sec / 60;
28352835
$sec -= ($min*60);
2836-
my $ret = sprintf "$hour %s", $hour==1 ? msg('time-hour') : msg('time-hours');
2837-
$min and $tweak !~ /M/ and $ret .= sprintf " $min %s", $min==1 ? msg('time-minute') : msg('time-minutes');
2838-
$sec and $tweak !~ /[SM]/ and $ret .= sprintf " $sec %s", $sec==1 ? msg('time-second') : msg('time-seconds');
2836+
my $ret = sprintf "$hour %s", 1==$hour ? msg('time-hour') : msg('time-hours');
2837+
$min and $tweak !~ /M/ and $ret .= sprintf " $min %s", 1==$min ? msg('time-minute') : msg('time-minutes');
2838+
$sec and $tweak !~ /[SM]/ and $ret .= sprintf " $sec %s", 1==$sec ? msg('time-second') : msg('time-seconds');
28392839
return $ret;
28402840
}
28412841

@@ -2847,10 +2847,10 @@ sub pretty_time {
28472847
$sec -= ($our*60*60);
28482848
my $min = int $sec / 60;
28492849
$sec -= ($min*60);
2850-
my $ret = sprintf "$day %s", $day==1 ? msg('time-day') : msg('time-days');
2851-
$our and $tweak !~ /H/ and $ret .= sprintf " $our %s", $our==1 ? msg('time-hour') : msg('time-hours');
2852-
$min and $tweak !~ /[HM]/ and $ret .= sprintf " $min %s", $min==1 ? msg('time-minute') : msg('time-minutes');
2853-
$sec and $tweak !~ /[HMS]/ and $ret .= sprintf " $sec %s", $sec==1 ? msg('time-second') : msg('time-seconds');
2850+
my $ret = sprintf "$day %s", 1==$day ? msg('time-day') : msg('time-days');
2851+
$our and $tweak !~ /H/ and $ret .= sprintf " $our %s", 1==$our ? msg('time-hour') : msg('time-hours');
2852+
$min and $tweak !~ /[HM]/ and $ret .= sprintf " $min %s", 1==$min ? msg('time-minute') : msg('time-minutes');
2853+
$sec and $tweak !~ /[HMS]/ and $ret .= sprintf " $sec %s", 1==$sec ? msg('time-second') : msg('time-seconds');
28542854
return $ret;
28552855
}
28562856

@@ -2863,11 +2863,11 @@ sub pretty_time {
28632863
$sec -= ($our*60*60);
28642864
my $min = int $sec / 60;
28652865
$sec -= ($min*60);
2866-
my $ret = sprintf "$week %s", $week==1 ? msg('time-week') : msg('time-weeks');
2867-
$day and $tweak !~ /D/ and $ret .= sprintf " $day %s", $day==1 ? msg('time-day') : msg('time-days');
2868-
$our and $tweak !~ /[DH]/ and $ret .= sprintf " $our %s", $our==1 ? msg('time-hour') : msg('time-hours');
2869-
$min and $tweak !~ /[DHM]/ and $ret .= sprintf " $min %s", $min==1 ? msg('time-minute') : msg('time-minutes');
2870-
$sec and $tweak !~ /[DHMS]/ and $ret .= sprintf " $sec %s", $sec==1 ? msg('time-second') : msg('time-seconds');
2866+
my $ret = sprintf "$week %s", 1==$week ? msg('time-week') : msg('time-weeks');
2867+
$day and $tweak !~ /D/ and $ret .= sprintf " $day %s", 1==$day ? msg('time-day') : msg('time-days');
2868+
$our and $tweak !~ /[DH]/ and $ret .= sprintf " $our %s", 1==$our ? msg('time-hour') : msg('time-hours');
2869+
$min and $tweak !~ /[DHM]/ and $ret .= sprintf " $min %s", 1==$min ? msg('time-minute') : msg('time-minutes');
2870+
$sec and $tweak !~ /[DHMS]/ and $ret .= sprintf " $sec %s", 1==$sec ? msg('time-second') : msg('time-seconds');
28712871
return $ret;
28722872

28732873
} ## end of pretty_time
@@ -3117,7 +3117,7 @@ sub run_command {
31173117
$db->{ok} = 1;
31183118

31193119
## Unfortunately, psql outputs "(No rows)" even with -t and -x
3120-
$db->{slurp} = '' if ! defined $db->{slurp} or index($db->{slurp},'(')==0;
3120+
$db->{slurp} = '' if ! defined $db->{slurp} or 0 == index($db->{slurp},'(');
31213121

31223122
## Remove carriage returns (i.e. on Win32)
31233123
$db->{slurp} =~ s/\r//g;
@@ -3162,7 +3162,7 @@ sub run_command {
31623162
my $lastval;
31633163
for my $line (split /\n/ => $db->{slurp}) {
31643164

3165-
if (index($line,'-')==0) {
3165+
if (0 == index($line,'-')) {
31663166
$lnum++;
31673167
next;
31683168
}
@@ -3573,7 +3573,7 @@ sub validate_range {
35733573
}
35743574
if (length $critical) {
35753575
if ($critical !~ $timesecre) {
3576-
ndie msg('range-seconds', 'critical')
3576+
ndie msg('range-seconds', 'critical');
35773577
}
35783578
$critical = $1;
35793579
if (!$arg->{any_warning} and length $warning and $warning > $critical) {
@@ -4174,7 +4174,7 @@ sub check_backends {
41744174
$nwarn = $limit-$w2;
41754175
}
41764176
elsif ($w3) {
4177-
$nwarn = (int $w2*$limit/100)
4177+
$nwarn = (int $w2*$limit/100);
41784178
}
41794179

41804180
if (! skip_item($r->{datname})) {
@@ -4404,7 +4404,7 @@ sub check_bloat {
44044404
qw/ iname irows ipages iotta ibloat wastedipgaes wastedibytes wastedisize/};
44054405

44064406
## Made it past the exclusions
4407-
$max = -2 if $max == -1;
4407+
$max = -2 if -1 == $max;
44084408

44094409
## Do the table first if we haven't seen it
44104410
if (! $seenit{"$dbname.$schema.$table"}++) {
@@ -4475,10 +4475,10 @@ sub check_bloat {
44754475
$db->{perf} = '';
44764476
}
44774477

4478-
if ($max == -1) {
4478+
if (-1 == $max) {
44794479
add_unknown msg('no-match-rel');
44804480
}
4481-
elsif ($max != -1) {
4481+
elsif (-1 != $max) {
44824482
add_ok $maxmsg;
44834483
}
44844484

@@ -4560,7 +4560,7 @@ sub check_checkpoint {
45604560
ndie msg('checkpoint-noparse', $last);
45614561
}
45624562
my $diff = time - $dt;
4563-
my $msg = $diff==1 ? msg('checkpoint-ok') : msg('checkpoint-ok2', $diff);
4563+
my $msg = 1==$diff ? msg('checkpoint-ok') : msg('checkpoint-ok2', $diff);
45644564
$db->{perf} = sprintf '%s=%s;%s;%s',
45654565
perfname(msg('age')), $diff, $warning, $critical;
45664566

@@ -5622,7 +5622,7 @@ sub check_hot_standby_delay {
56225622
## Do the check on replay delay in case SR has disconnected because it way too far behind
56235623
my $msg = qq{$rep_delta};
56245624
if ($version >= 9.1) {
5625-
$msg .= qq{ and $time_delta seconds}
5625+
$msg .= qq{ and $time_delta seconds};
56265626
}
56275627
if ((length $critical or length $ctime) and (!length $critical or length $critical and $rep_delta > $critical) and (!length $ctime or length $ctime and $time_delta > $ctime)) {
56285628
add_critical $msg;
@@ -5652,7 +5652,7 @@ sub check_replication_slots {
56525652

56535653
my ($warning, $critical) = validate_range({type => 'size'});
56545654

5655-
$SQL = qq{
5655+
$SQL = q{
56565656
WITH slots AS (SELECT slot_name,
56575657
slot_type,
56585658
coalesce(restart_lsn, '0/0'::pg_lsn) AS slot_lsn,
@@ -5679,7 +5679,7 @@ sub check_replication_slots {
56795679

56805680
for my $r (@{$db->{slurp}}) {
56815681
if (skip_item($r->{slot_name})) {
5682-
$max = -2 if ($max == -1 );
5682+
$max = -2 if -1 == $max;
56835683
next;
56845684
}
56855685
if ($r->{delta} >= $max) {
@@ -5692,14 +5692,14 @@ sub check_replication_slots {
56925692
}
56935693
if ($max < 0) {
56945694
$stats{$db->{dbname}} = 0;
5695-
add_ok msg('no-match-slotok') if ($max == -1);
5696-
add_unknown msg('no-match-slot') if ($max == -2);
5695+
add_ok msg('no-match-slotok') if -1 == $max;
5696+
add_unknown msg('no-match-slot') if -2 == $max;
56975697
next;
56985698
}
56995699

57005700
my $msg = '';
57015701
for (sort {$s{$b}[0] <=> $s{$a}[0] or $a cmp $b } keys %s) {
5702-
$msg .= "$_: $s{$_}[1] ($s{$_}[2] $s{$_}[3] " . ($s{$_}[4] eq 't'?'active':'inactive') .") ";
5702+
$msg .= "$_: $s{$_}[1] ($s{$_}[2] $s{$_}[3] " . ($s{$_}[4] eq 't' ? 'active' : 'inactive') .') ';
57035703
$db->{perf} .= sprintf ' %s=%s;%s;%s',
57045704
perfname($_), $s{$_}[0], $warning, $critical;
57055705
}
@@ -5836,7 +5836,7 @@ sub check_last_vacuum_analyze {
58365836
do_mrtg({one => $mintime, msg => $maxrel});
58375837
return;
58385838
}
5839-
if ($maxtime == -2) {
5839+
if (-2 == $maxtime) {
58405840
add_unknown (
58415841
$found ? $type eq 'vacuum' ? msg('vac-nomatch-v')
58425842
: msg('vac-nomatch-a')
@@ -6178,7 +6178,7 @@ sub check_logfile {
61786178
}
61796179
close $logfh or ndie msg('file-noclose', $logfile, $!);
61806180

6181-
if ($found == 1) {
6181+
if (1 == $found) {
61826182
$MRTG and do_mrtg({one => 1});
61836183
add_ok msg('logfile-ok', $logfile);
61846184
}
@@ -6607,7 +6607,7 @@ sub check_pgbouncer_backends {
66076607
$nwarn = $limit-$w2;
66086608
}
66096609
elsif ($w3) {
6610-
$nwarn = (int $w2*$limit/100)
6610+
$nwarn = (int $w2*$limit/100);
66116611
}
66126612

66136613
if (! skip_item($r->{database})) {
@@ -6890,15 +6890,17 @@ sub check_relation_size {
68906890

68916891
my ($warning, $critical) = validate_range({type => 'size'});
68926892

6893+
## no critic
68936894
$SQL = sprintf q{
68946895
SELECT pg_%1$s_size(c.oid) AS rsize,
68956896
pg_size_pretty(pg_%1$s_size(c.oid)) AS psize,
68966897
relkind, relname, nspname
68976898
FROM pg_class c JOIN pg_namespace n ON (c.relnamespace = n.oid)
68986899
WHERE relkind IN (%2$s)
68996900
},
6900-
$sizefct,
6901-
join (',', map { "'$_'" } split (//, $relkinds));
6901+
$sizefct, ## no critic
6902+
join (',', map { "'$_'" } split (//, $relkinds)); ## no critic
6903+
## use critic
69026904

69036905
if ($opt{perflimit}) {
69046906
$SQL .= " ORDER BY 1 DESC LIMIT $opt{perflimit}";
@@ -6934,7 +6936,7 @@ sub check_relation_size {
69346936
my $nicename = $kind eq 'r' ? "$schema.$name" : $name;
69356937

69366938
$db->{perf} .= sprintf '%s%s=%sB;%s;%s',
6937-
$VERBOSE==1 ? "\n" : ' ',
6939+
1 == $VERBOSE ? "\n" : ' ',
69386940
perfname($nicename), $size, $warning, $critical;
69396941
($max=$size, $pmax=$psize, $kmax=$kind, $nmax=$name, $smax=$schema) if $size > $max;
69406942
}
@@ -8268,7 +8270,7 @@ sub check_sequence {
82688270
FROM pg_sequences) foo};
82698271
## use critic
82708272

8271-
my $info = run_command($SQL, {regex => qr{\w}, emptyok => 1, version => [">9.6 SELECT 1"]} ); # actual SQL10 is executed below
8273+
my $info = run_command($SQL, {regex => qr{\w}, emptyok => 1, version => ['>9.6 SELECT 1']} ); # actual SQL10 is executed below
82728274

82738275
my $MAXINT2 = 32767;
82748276
my $MAXINT4 = 2147483647;
@@ -8955,7 +8957,7 @@ sub check_wal_files {
89558957
my ($warning, $critical) = validate_range($arg);
89568958

89578959
my $lsfunc = $opt{lsfunc} || 'pg_ls_dir';
8958-
my $lsargs = $opt{lsfunc} ? "" : "'pg_xlog$subdir'";
8960+
my $lsargs = $opt{lsfunc} ? q{} : "'pg_xlog$subdir'";
89598961

89608962
## Figure out where the pg_xlog directory is
89618963
$SQL = qq{SELECT count(*) AS count FROM $lsfunc($lsargs) WHERE $lsfunc ~ E'^[0-9A-F]{24}$extrabit\$'}; ## no critic (RequireInterpolationOfMetachars)
@@ -9135,17 +9137,17 @@ =head1 DATABASE CONNECTION OPTIONS
91359137
=item B<--dbservice=NAME>
91369138
91379139
The name of a service inside of the pg_service.conf file. Before version 9.0 of Postgres, this is
9138-
a global file, usually found in /etc/pg_service.conf. If you are using version 9.0 or higher of
9140+
a global file, usually found in F</etc/pg_service.conf>. If you are using version 9.0 or higher of
91399141
Postgres, you can use the file ".pg_service.conf" in the home directory of the user running
91409142
the script, e.g. nagios.
91419143
91429144
This file contains a simple list of connection options. You can also pass additional information
91439145
when using this option such as --dbservice="maindatabase sslmode=require"
91449146
91459147
The documentation for this file can be found at
9146-
https://www.postgresql.org/docs/current/static/libpq-pgservice.html
9148+
L<https://www.postgresql.org/docs/current/static/libpq-pgservice.html>
9149+
91479150
9148-
=back
91499151
91509152
The database connection options can be grouped: I<--host=a,b --host=c --port=1234 --port=3344>
91519153
would connect to a-1234, b-1234, and c-3344. Note that once set, an option
@@ -9821,7 +9823,7 @@ =head2 B<disk_space>
98219823
98229824
check_postgres_disk_space --port=5432 --warning='90%' --critical='90%'
98239825
9824-
Example 2: Check that all file systems starting with /dev/sda are smaller than 10 GB and 11 GB (warning and critical)
9826+
Example 2: Check that all file systems starting with F</dev/sda> are smaller than 10 GB and 11 GB (warning and critical)
98259827
98269828
check_postgres_disk_space --port=5432 --warning='10 GB' --critical='11 GB' --include="~^/dev/sda"
98279829
@@ -10115,7 +10117,7 @@ =head2 B<new_version_bc>
1011510117
program is available. The current version is obtained by running C<bucardo_ctl --version>.
1011610118
If a major upgrade is available, a warning is returned. If a revision upgrade is
1011710119
available, a critical is returned. (Bucardo is a master to slave, and master to master
10118-
replication system for Postgres: see https://bucardo.org/ for more information).
10120+
replication system for Postgres: see L<https://bucardo.org/> for more information).
1011910121
See also the information on the C<--get_method> option.
1012010122
1012110123
=head2 B<new_version_box>
@@ -10125,7 +10127,7 @@ =head2 B<new_version_box>
1012510127
If a major upgrade is available, a warning is returned. If a revision upgrade is
1012610128
available, a critical is returned. (boxinfo is a program for grabbing important
1012710129
information from a server and putting it into a HTML format: see
10128-
https://bucardo.org/Boxinfo/ for more information). See also the information on
10130+
L<https://bucardo.org/Boxinfo/> for more information). See also the information on
1012910131
the C<--get_method> option.
1013010132
1013110133
=head2 B<new_version_cp>
@@ -10154,7 +10156,7 @@ =head2 B<new_version_tnm>
1015410156
C<tail_n_mail --version>. If a major upgrade is available, a warning is returned. If a
1015510157
revision upgrade is available, a critical is returned. (tail_n_mail is a log monitoring
1015610158
tool that can send mail when interesting events appear in your Postgres logs.
10157-
See: https://bucardo.org/tail_n_mail/ for more information).
10159+
See: L<https://bucardo.org/tail_n_mail/> for more information).
1015810160
See also the information on the C<--get_method> option.
1015910161
1016010162
=head2 B<pgb_pool_cl_active>
@@ -10861,7 +10863,7 @@ =head1 FILES
1086110863
1086210864
In addition to command-line configurations, you can put any options inside of a file. The file
1086310865
F<.check_postgresrc> in the current directory will be used if found. If not found, then the file
10864-
F<~/.check_postgresrc> will be used. Finally, the file /etc/check_postgresrc will be used if available.
10866+
F<~/.check_postgresrc> will be used. Finally, the file F</etc/check_postgresrc> will be used if available.
1086510867
The format of the file is option = value, one per line. Any line starting with a '#' will be skipped.
1086610868
Any values loaded from a check_postgresrc file will be overwritten by command-line options. All
1086710869
check_postgresrc files can be ignored by supplying a C<--no-checkpostgresrc> argument.
@@ -10918,17 +10920,17 @@ =head1 MAILING LIST
1091810920
Three mailing lists are available. For discussions about the program, bug reports,
1091910921
feature requests, and commit notices, send email to check_postgres@bucardo.org
1092010922
10921-
https://mail.endcrypt.com/mailman/listinfo/check_postgres
10923+
L<https://mail.endcrypt.com/mailman/listinfo/check_postgres>
1092210924
1092310925
A low-volume list for announcement of new versions and important notices is the
1092410926
'check_postgres-announce' list:
1092510927
10926-
https://mail.endcrypt.com/mailman/listinfo/check_postgres-announce
10928+
L<https://mail.endcrypt.com/mailman/listinfo/check_postgres-announce>
1092710929
1092810930
Source code changes (via git-commit) are sent to the
1092910931
'check_postgres-commit' list:
1093010932
10931-
https://mail.endcrypt.com/mailman/listinfo/check_postgres-commit
10933+
L<https://mail.endcrypt.com/mailman/listinfo/check_postgres-commit>
1093210934
1093310935
=head1 HISTORY
1093410936

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