diff options
Diffstat (limited to 't/Nagios-Plugin.t')
-rw-r--r-- | t/Nagios-Plugin.t | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/t/Nagios-Plugin.t b/t/Nagios-Plugin.t index 38e792d..ed25aca 100644 --- a/t/Nagios-Plugin.t +++ b/t/Nagios-Plugin.t | |||
@@ -1,18 +1,22 @@ | |||
1 | 1 | ||
2 | use strict; | 2 | use strict; |
3 | use Test::More tests => 5; | 3 | use Test::More tests => 9; |
4 | |||
4 | BEGIN { use_ok('Nagios::Plugin') }; | 5 | BEGIN { use_ok('Nagios::Plugin') }; |
5 | 6 | ||
6 | use Nagios::Plugin::Base; | 7 | use Nagios::Plugin::Base; |
7 | Nagios::Plugin::Base->exit_on_die(0); | 8 | Nagios::Plugin::Base->exit_on_die(0); |
8 | Nagios::Plugin::Base->print_on_die(0); | 9 | Nagios::Plugin::Base->print_on_die(0); |
9 | 10 | ||
11 | diag "\nusing Nagios::Plugin revision ". $Nagios::Plugin::VERSION . "\n"; | ||
12 | |||
10 | my $p = Nagios::Plugin->new; | 13 | my $p = Nagios::Plugin->new; |
11 | isa_ok( $p, "Nagios::Plugin"); | 14 | isa_ok( $p, "Nagios::Plugin"); |
12 | 15 | ||
13 | $p->shortname("PAGESIZE"); | 16 | $p->shortname("PAGESIZE"); |
14 | 17 | ||
15 | my $t = $p->set_thresholds( warning => "10:25", critical => "25:" ); | 18 | diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE}; |
19 | my $t = $p->set_thresholds( warning => "10:25", critical => "~:25" ); | ||
16 | 20 | ||
17 | $p->add_perfdata( | 21 | $p->add_perfdata( |
18 | label => "size", | 22 | label => "size", |
@@ -21,12 +25,20 @@ $p->add_perfdata( | |||
21 | threshold => $t, | 25 | threshold => $t, |
22 | ); | 26 | ); |
23 | 27 | ||
24 | cmp_ok( $p->all_perfoutput, 'eq', "size=1kB;10:25;25:", "Perfdata correct"); | 28 | cmp_ok( $p->all_perfoutput, 'eq', "size=1kB;10:25;~:25", "Perfdata correct"); |
25 | 29 | ||
26 | my $o = $p->die( return_code => $t->get_status(1), message => "page size at http://... was 1kB" ); | 30 | my $expected = {qw( |
27 | cmp_ok( $o, "eq", 'PAGESIZE CRITICAL page size at http://... was 1kB | size=1kB;10:25;25:', "Output okay"); | 31 | -1 WARNING |
28 | 32 | 1 WARNING | |
29 | cmp_ok( $p->die( return_code => $t->get_status(30), message => "page size at http://... was 30kB" ), | 33 | 20 OK |
30 | "eq", 'PAGESIZE WARNING page size at http://... was 30kB | size=1kB;10:25;25:', "Output okay"); | 34 | 25 OK |
31 | 35 | 26 CRITICAL | |
36 | 30 CRITICAL | ||
37 | )}; | ||
38 | |||
39 | foreach (sort {$a<=>$b} keys %$expected) { | ||
40 | like $p->die( return_code => $t->get_status($_), message => "page size at http://... was ${_}kB" ), | ||
41 | qr/$expected->{$_}/, | ||
42 | "Output okay. $_ = $expected->{$_}" ; | ||
43 | } | ||
32 | 44 | ||