diff options
author | Greg Sabino Mullane | 2009-04-30 12:35:13 +0000 |
---|---|---|
committer | Greg Sabino Mullane | 2009-04-30 12:35:13 +0000 |
commit | 668b60defbc7e71725a6a51b64b10d475e3f7a92 (patch) | |
tree | 15b4b1a828877241eef3e7898db5f5decd30e3c8 | |
parent | dfb6529adbd12f36e8ca11d1242c9de9d9b5f485 (diff) |
Don't allow values over 2 billion for wraparound check.
Older version compatibility.
-rwxr-xr-x | check_postgres.pl | 11 | ||||
-rw-r--r-- | t/02_txn_wraparound.t | 31 |
2 files changed, 30 insertions, 12 deletions
diff --git a/check_postgres.pl b/check_postgres.pl index b778462d8..8bd874cb3 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -262,6 +262,8 @@ our %msg = ( 'txntime-fail' => q{Query failed}, 'txntime-msg' => q{longest txn: $1s}, 'txntime-none' => q{No transactions}, + 'txnwrap-wbig' => q{The 'warning' value must be less than 2 billion}, + 'txnwrap-cbig' => q{The 'critical' value must be less than 2 billion}, 'unknown-error' => q{Unknown error}, 'usage' => qq{\nUsage: \$1 <options>\n Try "\$1 --help" for a complete list of options\n\n}, 'vac-msg' => q{DB: $1 TABLE: $2}, @@ -451,6 +453,8 @@ our %msg = ( 'txntime-fail' => q{Échec de la requête}, 'txntime-msg' => q{Transaction la plus longue : $1s}, 'txntime-none' => q{Aucune transaction}, +'txnwrap-wbig' => q{The 'warning' value must be less than 2 billion}, +'txnwrap-cbig' => q{The 'critical' value must be less than 2 billion}, 'unknown-error' => q{erreur inconnue}, 'usage' => qq{\nUsage: \$1 <options>\n Essayez « \$1 --help » pour liste complète des options\n\n}, 'vac-msg' => q{Base de données : $1 Table : $2}, @@ -3905,6 +3909,13 @@ sub check_txn_wraparound { default_critical => 1_400_000_000, }); + if ($warning and $warning >= 2_000_000_000) { + ndie msg('txnwrap-wbig'); + } + if ($critical and $critical >= 2_000_000_000) { + ndie msg('txnwrap-cbig'); + } + $SQL = q{SELECT datname, age(datfrozenxid) FROM pg_database WHERE datallowconn ORDER BY 1, 2}; my $info = run_command($SQL, { regex => qr[\w+\s+\|\s+\d+] } ); diff --git a/t/02_txn_wraparound.t b/t/02_txn_wraparound.t index 8e0610088..c44af2a12 100644 --- a/t/02_txn_wraparound.t +++ b/t/02_txn_wraparound.t @@ -6,7 +6,7 @@ use 5.006; use strict; use warnings; use Data::Dumper; -use Test::More tests => 14; +use Test::More tests => 16; use lib 't','.'; use CP_Testing; @@ -30,35 +30,42 @@ like ($result, qr{^$label}, $t); $t = qq{$S identifies each database}; like ($result, qr{ardala=\d+ beedeebeedee=\d+ postgres=\d+ template1=\d+}, $t); -my $txn_measure; $result =~ /ardala=(\d+)/; -$txn_measure = $1; +my $txn_measure = $1; $t = qq{$S identifies host}; like ($result, qr{host:$host}, $t); +## 8.1 starts a little over 1 billion $t = qq{$S accepts valid -w input}; -like ($cp->run(q{-w 1000000}), qr/$label OK/, $t); +like ($cp->run(q{-w 1500000000}), qr{$label OK}, $t); $t = qq{$S flags invalid -w input}; -for (-1, 0, 'a') { - like ($cp->run(qq{-w $_}), qr/ERROR: Invalid argument.*must be a positive integer/, $t . " ($_)"); +for my $arg (-1, 0, 'a') { + like ($cp->run(qq{-w $arg}), qr{ERROR: Invalid argument.*must be a positive integer}, "$t ($arg)"); } +$t = qq{$S rejects warning values 2 billion or higher}; +like ($cp->run(qq{-w 2000000000}), qr{ERROR:.+less than 2 billion}, $t); + +$t = qq{$S rejects critical values 2 billion or higher}; +like ($cp->run(qq{-c 2200000000}), qr{ERROR:.+less than 2 billion}, $t); + $t = qq{$S accepts valid -c input}; -like ($cp->run(q{-c 1000000}), qr/$label OK/, $t); +like ($cp->run(q{-c 1400000000}), qr{$label OK}, $t); $t = qq{$S flags invalid -c input}; -for (-1, 0, 'a') { - like ($cp->run(qq{-c $_}), qr/ERROR: Invalid argument.*must be a positive integer/, $t . " ($_)"); +for my $arg (-1, 0, 'a') { + like ($cp->run(qq{-c $arg}), qr{ERROR: Invalid argument.*must be a positive integer}, "$t ($arg)"); } $t = qq{$S sees impending wrap-around}; -like ($cp->run('-c ' . int ($txn_measure / 2)), qr/$label CRITICAL/, $t); +like ($cp->run('-c ' . int ($txn_measure / 2)), qr{$label CRITICAL}, $t); $t = qq{$S sees no impending wrap-around}; -like ($cp->run('-v -c ' . ($txn_measure * 2)), qr/$label OK/, $t); +like ($cp->run('-c 1999000000'), qr{$label OK}, $t); $t .= ' (mrtg)'; -like ($cp->run('-c 100000 --output=mrtg'), qr{\d+\n0\n\nDB: ardala}, $t); +like ($cp->run('-c 1400000000 --output=mrtg'), qr{\d+\n0\n\nDB: \w+}, $t); +exit; |