summaryrefslogtreecommitdiffstats
path: root/t/Monitoring-Plugin-01.t
diff options
context:
space:
mode:
authorSven Nierlein <sven@nierlein.de>2014-01-20 00:54:34 +0100
committerSven Nierlein <sven@nierlein.de>2014-01-20 00:54:34 +0100
commitb418181dfe80dd75169b6e8a619ac1932155dea2 (patch)
treecad9c0ae0eae8e800cfff60555ead06ad33c6856 /t/Monitoring-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/Monitoring-Plugin-01.t')
-rw-r--r--t/Monitoring-Plugin-01.t71
1 files changed, 71 insertions, 0 deletions
diff --git a/t/Monitoring-Plugin-01.t b/t/Monitoring-Plugin-01.t
new file mode 100644
index 0000000..f5882a5
--- /dev/null
+++ b/t/Monitoring-Plugin-01.t
@@ -0,0 +1,71 @@
1# Monitoring::Plugin original test cases
2
3use strict;
4use Test::More tests => 15;
5
6BEGIN { use_ok('Monitoring::Plugin') };
7
8use Monitoring::Plugin::Functions;
9Monitoring::Plugin::Functions::_fake_exit(1);
10
11diag "\nusing Monitoring::Plugin revision ". $Monitoring::Plugin::VERSION . "\n"
12 if $ENV{TEST_VERBOSE};
13
14my $p = Monitoring::Plugin->new();
15isa_ok( $p, "Monitoring::Plugin");
16
17$p->shortname("PAGESIZE");
18is($p->shortname, "PAGESIZE", "shortname explicitly set correctly");
19
20$p = Monitoring::Plugin->new();
21is($p->shortname, "MONITORING-PLUGIN-01", "shortname should default on new");
22
23$p = Monitoring::Plugin->new( shortname => "SIZE", () );
24is($p->shortname, "SIZE", "shortname set correctly on new");
25
26$p = Monitoring::Plugin->new( plugin => "check_stuff", () );
27is($p->shortname, "STUFF", "shortname uses plugin name as default");
28
29$p = Monitoring::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}