summaryrefslogtreecommitdiffstats
path: root/t/Nagios-Plugin-01.t
diff options
context:
space:
mode:
authorSven Nierlein <sven@nierlein.de>2014-01-19 23:54:34 (GMT)
committerSven Nierlein <sven@nierlein.de>2014-01-19 23:54:34 (GMT)
commitb418181dfe80dd75169b6e8a619ac1932155dea2 (patch)
treecad9c0ae0eae8e800cfff60555ead06ad33c6856 /t/Nagios-Plugin-01.t
parent1cd8d1c52cbd47121f344c4074aec84653f412ce (diff)
downloadmonitoring-plugin-perl-b418181dfe80dd75169b6e8a619ac1932155dea2.tar.gz
renamed module into Monitoring::Plugin
since the complete monitoring team has been renamed, we also rename this module. Signed-off-by: Sven Nierlein <sven@nierlein.de>
Diffstat (limited to 't/Nagios-Plugin-01.t')
-rw-r--r--t/Nagios-Plugin-01.t72
1 files changed, 0 insertions, 72 deletions
diff --git a/t/Nagios-Plugin-01.t b/t/Nagios-Plugin-01.t
deleted file mode 100644
index 947a704..0000000
--- a/t/Nagios-Plugin-01.t
+++ /dev/null
@@ -1,72 +0,0 @@
1# Nagios::Plugin original test cases
2
3use strict;
4use Test::More tests => 15;
5
6BEGIN { use_ok('Nagios::Plugin') };
7
8use Nagios::Plugin::Functions;
9Nagios::Plugin::Functions::_fake_exit(1);
10
11diag "\nusing Nagios::Plugin revision ". $Nagios::Plugin::VERSION . "\n"
12 if $ENV{TEST_VERBOSE};
13
14my $p = Nagios::Plugin->new();
15isa_ok( $p, "Nagios::Plugin");
16
17$p->shortname("PAGESIZE");
18is($p->shortname, "PAGESIZE", "shortname explicitly set correctly");
19
20$p = Nagios::Plugin->new();
21is($p->shortname, "NAGIOS-PLUGIN-01", "shortname should default on new");
22
23$p = Nagios::Plugin->new( shortname => "SIZE", () );
24is($p->shortname, "SIZE", "shortname set correctly on new");
25
26$p = Nagios::Plugin->new( plugin => "check_stuff", () );
27is($p->shortname, "STUFF", "shortname uses plugin name as default");
28
29$p = Nagios::Plugin->new( shortname => "SIZE", plugin => "check_stuff", () );
30is($p->shortname, "SIZE", "shortname is not overriden by default");
31
32diag "warn if < 10, critical if > 25 " if $ENV{TEST_VERBOSE};
33my $t = $p->set_thresholds( warning => "10:25", critical => "~:25" );
34
35use Data::Dumper;
36#diag "dumping p: ". Dumper $p;
37#diag "dumping perfdata: ". Dumper $p->perfdata;
38
39
40$p->add_perfdata(
41 label => "size",
42 value => 1,
43 uom => "kB",
44 threshold => $t,
45 );
46
47cmp_ok( $p->all_perfoutput, 'eq', "size=1kB;10:25;~:25", "Perfdata correct");
48#diag "dumping perfdata: ". Dumper ($p->perfdata);
49
50$p->add_perfdata(
51 label => "time",
52 value => "3.52",
53 threshold => $t,
54 );
55
56is( $p->all_perfoutput, "size=1kB;10:25;~:25 time=3.52;10:25;~:25", "Perfdata correct when no uom specified");
57
58my $expected = {qw(
59 -1 WARNING
60 1 WARNING
61 20 OK
62 25 OK
63 26 CRITICAL
64 30 CRITICAL
65 )};
66
67foreach (sort {$a<=>$b} keys %$expected) {
68 like $p->die( return_code => $t->get_status($_), message => "page size at http://... was ${_}kB" ),
69 qr/$expected->{$_}/,
70 "Output okay. $_ = $expected->{$_}" ;
71}
72