diff options
| author | Ton Voon <tonvoon@users.sourceforge.net> | 2008-03-17 20:32:11 +0000 |
|---|---|---|
| committer | Ton Voon <tonvoon@users.sourceforge.net> | 2008-03-17 20:32:11 +0000 |
| commit | 9d5427f392b4b03b7fd558b4be628653d140f6c0 (patch) | |
| tree | 6d52797148baf7371071c05d98a6b60e97f1e6e2 /t | |
| parent | 405590a12a5552df48d8153f91e529bad0a9c528 (diff) | |
| download | monitoring-plugin-perl-9d5427f392b4b03b7fd558b4be628653d140f6c0.tar.gz | |
Fixed parsing of negative values and support full range definitions
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1952 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 't')
| -rw-r--r-- | t/Nagios-Plugin-Performance.t | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/t/Nagios-Plugin-Performance.t b/t/Nagios-Plugin-Performance.t index 0574ea0..7a28546 100644 --- a/t/Nagios-Plugin-Performance.t +++ b/t/Nagios-Plugin-Performance.t | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | ||
| 2 | use strict; | 2 | use strict; |
| 3 | use Test::More tests => 91; | 3 | use Test::More tests => 111; |
| 4 | BEGIN { use_ok('Nagios::Plugin::Performance') }; | 4 | BEGIN { use_ok('Nagios::Plugin::Performance') }; |
| 5 | 5 | ||
| 6 | diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n" if $ENV{TEST_VERBOSE}; | 6 | diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n" if $ENV{TEST_VERBOSE}; |
| @@ -142,4 +142,33 @@ cmp_ok( $p[0]->uom, "eq", "%", "uom okay"); | |||
| 142 | cmp_ok( $p[0]->threshold->warning, 'eq', "90", "warn okay"); | 142 | cmp_ok( $p[0]->threshold->warning, 'eq', "90", "warn okay"); |
| 143 | cmp_ok( $p[0]->threshold->critical, 'eq', "95", "crit okay"); | 143 | cmp_ok( $p[0]->threshold->critical, 'eq', "95", "crit okay"); |
| 144 | 144 | ||
| 145 | # Check ranges are parsed correctly | ||
| 146 | @p = Nagios::Plugin::Performance->parse_perfstring("availability=93.8%;90:99;"); | ||
| 147 | is( $p[0]->label, "availability", "label okay"); | ||
| 148 | is( $p[0]->value, "93.8", "value okay"); | ||
| 149 | is( $p[0]->uom, "%", "uom okay"); | ||
| 150 | ok( defined eval { $p[0]->threshold->warning->is_set }, "Warning range has been set"); | ||
| 151 | is( $p[0]->threshold->critical->is_set, 0, "Critical range has not been set"); | ||
| 152 | is( $p[0]->threshold->warning, "90:99", "warn okay"); | ||
| 153 | |||
| 154 | # Check that negative values are parsed correctly in value and ranges | ||
| 155 | @p = Nagios::Plugin::Performance->parse_perfstring("offset=-0.004476s;-60.000000:-5;-120.000000:-3;"); | ||
| 156 | is( $p[0]->label, "offset", "label okay"); | ||
| 157 | is( $p[0]->value, "-0.004476", "value okay"); | ||
| 158 | is( $p[0]->uom, "s", "uom okay"); | ||
| 159 | ok( defined eval { $p[0]->threshold->warning->is_set }, "Warning range has been set"); | ||
| 160 | ok( defined eval { $p[0]->threshold->critical->is_set }, "Critical range has been set"); | ||
| 161 | is( $p[0]->threshold->warning, "-60:-5", "warn okay"); | ||
| 162 | is( $p[0]->threshold->critical, "-120:-3", "crit okay"); | ||
| 163 | |||
| 164 | # Check infinity values are okay | ||
| 165 | @p = Nagios::Plugin::Performance->parse_perfstring("salary=52GBP;~:23;45:"); | ||
| 166 | is( $p[0]->label, "salary", "label okay"); | ||
| 167 | is( $p[0]->value, "52", "value okay"); | ||
| 168 | is( $p[0]->uom, "GBP", "uom okay"); | ||
| 169 | ok( defined eval { $p[0]->threshold->warning->is_set }, "Warning range has been set"); | ||
| 170 | is( $p[0]->threshold->critical->is_set, 1, "Critical range has been set"); | ||
| 171 | is( $p[0]->threshold->warning, "~:23", "warn okay"); | ||
| 172 | is( $p[0]->threshold->critical, "45:", "warn okay"); | ||
| 173 | |||
| 145 | # add_perfdata tests in t/Nagios-Plugin-01.t | 174 | # add_perfdata tests in t/Nagios-Plugin-01.t |
