1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#!perl
## Test the "txn_wraparound" action
use 5.008;
use strict;
use warnings;
use Data::Dumper;
use Test::More tests => 16;
use lib 't','.';
use CP_Testing;
use vars qw/$dbh $result $t $host $dbname $testtbl $testtrig_prefix/;
$testtbl = 'test_txn_wraparound';
$testtrig_prefix = 'test_txn_wraparound_';
my $cp = CP_Testing->new( {default_action => 'txn_wraparound'} );
$dbh = $cp->test_database_handle();
$dbname = $cp->get_dbname;
$host = $cp->get_host();
my $S = q{Action 'txn_wraparound'};
my $label = 'POSTGRES_TXN_WRAPAROUND';
$t = qq{$S self-identifies correctly};
$result = $cp->run();
like ($result, qr{^$label}, $t);
$t = qq{$S identifies each database};
like ($result, qr{ardala=\d+;1300000000;1400000000;0;2000000000 beedeebeedee=\d+;1300000000;1400000000;0;2000000000 postgres=\d+;1300000000;1400000000;0;2000000000 template1=\d+;1300000000;1400000000;0;2000000000}, $t);
$result =~ /ardala=(\d+)/;
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 1500000000}), qr{$label OK}, $t);
$t = qq{$S flags invalid -w input};
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(q{-w 2000000000}), qr{ERROR:.+less than 2 billion}, $t);
$t = qq{$S rejects critical values 2 billion or higher};
like ($cp->run(q{-c 2200000000}), qr{ERROR:.+less than 2 billion}, $t);
$t = qq{$S accepts valid -c input};
like ($cp->run(q{-c 1400000000}), qr{$label OK}, $t);
$t = qq{$S flags invalid -c input};
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);
$t = qq{$S sees no impending wrap-around};
like ($cp->run('-c 1999000000'), qr{$label OK}, $t);
$t .= ' (mrtg)';
like ($cp->run('-c 1400000000 --output=mrtg'), qr{\d+\n0\n\nDB: \w+}, $t);
exit;
|