summaryrefslogtreecommitdiffstats
path: root/t/Nagios-Plugin-Performance.t
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-06-08 12:27:44 +0000
committerTon Voon <tonvoon@users.sourceforge.net>2006-06-08 12:27:44 +0000
commit2c6651034f76e2bccb549a867485f8fabbf07cb1 (patch)
tree8de53d7efe4564017e1ebce73353c7e3a3c8b548 /t/Nagios-Plugin-Performance.t
parent83e29d795dddf34a652cda8665179b77372ddcfe (diff)
downloadmonitoring-plugin-perl-2c6651034f76e2bccb549a867485f8fabbf07cb1.tar.gz
Initial revision
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1419 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 't/Nagios-Plugin-Performance.t')
-rw-r--r--t/Nagios-Plugin-Performance.t63
1 files changed, 63 insertions, 0 deletions
diff --git a/t/Nagios-Plugin-Performance.t b/t/Nagios-Plugin-Performance.t
new file mode 100644
index 0000000..2fe2326
--- /dev/null
+++ b/t/Nagios-Plugin-Performance.t
@@ -0,0 +1,63 @@
1
2use strict;
3use Test::More tests => 42;
4BEGIN { use_ok('Nagios::Plugin::Performance') };
5
6use Nagios::Plugin::Base;
7Nagios::Plugin::Base->exit_on_die(0);
8
9my @p = Nagios::Plugin::Performance->parse_perfstring("/=382MB;15264;15269;; /var=218MB;9443;9448");
10cmp_ok( $p[0]->label, 'eq', "/", "label okay");
11cmp_ok( $p[0]->value, '==', 382, "value okay");
12cmp_ok( $p[0]->uom, 'eq', "MB", "uom okay");
13cmp_ok( $p[0]->threshold->warning->end, "==", 15264, "warn okay");
14cmp_ok( $p[0]->threshold->critical->end, "==", 15269, "crit okay");
15ok( ! defined $p[0]->min, "min okay");
16ok( ! defined $p[0]->max, "max okay");
17
18cmp_ok( $p[1]->label, 'eq', "/var", "label okay");
19cmp_ok( $p[1]->value, '==', 218, "value okay");
20cmp_ok( $p[1]->uom, 'eq', "MB", "uom okay");
21cmp_ok( $p[1]->threshold->warning->end, "==", 9443, "warn okay");
22cmp_ok( $p[1]->threshold->critical->end, "==", 9448, "crit okay");
23
24ok( ! defined Nagios::Plugin::Performance->parse_perfstring("rubbish"), "Errors correctly");
25ok( ! defined Nagios::Plugin::Performance->parse_perfstring(""), "Errors on empty string");
26
27@p = Nagios::Plugin::Performance->parse_perfstring(
28 "time=0.001229s;0.000000;0.000000;0.000000;10.000000");
29cmp_ok( $p[0]->label, "eq", "time", "label okay");
30cmp_ok( $p[0]->value, "==", 0.001229, "value okay");
31cmp_ok( $p[0]->uom, "eq", "s", "uom okay");
32cmp_ok( $p[0]->threshold->warning, "eq", "0", "warn okay");
33cmp_ok( $p[0]->threshold->critical, "eq", "0", "crit okay");
34
35@p = Nagios::Plugin::Performance->parse_perfstring(
36 "load1=0.000;5.000;9.000;0; load5=0.000;5.000;9.000;0; load15=0.000;5.000;9.000;0;");
37cmp_ok( $p[0]->label, "eq", "load1", "label okay");
38cmp_ok( $p[0]->value, "eq", "0", "value okay with 0 as string");
39cmp_ok( $p[0]->uom, "eq", "", "uom empty");
40cmp_ok( $p[0]->threshold->warning, "eq", "5", "warn okay");
41cmp_ok( $p[0]->threshold->critical, "eq", "9", "crit okay");
42cmp_ok( $p[1]->label, "eq", "load5", "label okay");
43cmp_ok( $p[2]->label, "eq", "load15", "label okay");
44
45@p = Nagios::Plugin::Performance->parse_perfstring( "users=4;20;50;0" );
46cmp_ok( $p[0]->label, "eq", "users", "label okay");
47cmp_ok( $p[0]->value, "==", 4, "value okay");
48cmp_ok( $p[0]->uom, "eq", "", "uom empty");
49cmp_ok( $p[0]->threshold->warning, 'eq', "20", "warn okay");
50cmp_ok( $p[0]->threshold->critical, 'eq', "50", "crit okay");
51
52@p = Nagios::Plugin::Performance->parse_perfstring(
53 "time=0.215300s;5.000000;10.000000;0.000000 size=426B;;;0" );
54cmp_ok( $p[0]->label, "eq", "time", "label okay");
55cmp_ok( $p[0]->value, "eq", "0.2153", "value okay");
56cmp_ok( $p[0]->uom, "eq", "s", "uom okay");
57cmp_ok( $p[0]->threshold->warning, 'eq', "5", "warn okay");
58cmp_ok( $p[0]->threshold->critical, 'eq', "10", "crit okay");
59cmp_ok( $p[1]->label, "eq", "size", "label okay");
60cmp_ok( $p[1]->value, "==", 426, "value okay");
61cmp_ok( $p[1]->uom, "eq", "B", "uom okay");
62 ok( ! defined $p[1]->threshold->warning, "warn okay");
63 ok( ! defined $p[1]->threshold->critical, "crit okay");