summaryrefslogtreecommitdiffstats
path: root/t/Nagios-Plugin.t
blob: 38e792d3e7354cd28007124075f0e4700f1d3518 (plain)
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

use strict;
use Test::More tests => 5;
BEGIN { use_ok('Nagios::Plugin') };

use Nagios::Plugin::Base;
Nagios::Plugin::Base->exit_on_die(0);
Nagios::Plugin::Base->print_on_die(0);

my $p = Nagios::Plugin->new;
isa_ok( $p, "Nagios::Plugin");

$p->shortname("PAGESIZE");

my $t = $p->set_thresholds( warning => "10:25", critical => "25:" );

$p->add_perfdata( 
	label => "size", 
	value => 1, 
	uom => "kB", 
	threshold => $t,
	);

cmp_ok( $p->all_perfoutput, 'eq', "size=1kB;10:25;25:", "Perfdata correct");

my $o = $p->die( return_code => $t->get_status(1), message => "page size at http://... was 1kB" );
cmp_ok( $o, "eq", 'PAGESIZE CRITICAL page size at http://... was 1kB | size=1kB;10:25;25:', "Output okay");

cmp_ok( $p->die( return_code => $t->get_status(30), message => "page size at http://... was 30kB" ),
	"eq", 'PAGESIZE WARNING page size at http://... was 30kB | size=1kB;10:25;25:', "Output okay");