diff options
author | Gavin Carr <gonzai@users.sourceforge.net> | 2007-03-16 11:25:15 +0000 |
---|---|---|
committer | Gavin Carr <gonzai@users.sourceforge.net> | 2007-03-16 11:25:15 +0000 |
commit | c6cbf050974c8f6642fa1d7bde309710b66cbfa0 (patch) | |
tree | 0eb0ea62814b0623fb619c2af3287a585de48c2c /lib/Nagios/Plugin/Range.pm | |
parent | e5109f99c9657a1a8e9fb32b19254a417e2ccd65 (diff) | |
download | monitoring-plugin-perl-c6cbf050974c8f6642fa1d7bde309710b66cbfa0.tar.gz |
Cleanups, mostly to N::P::Range/Threshold/Performance.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1641 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/Nagios/Plugin/Range.pm')
-rw-r--r-- | lib/Nagios/Plugin/Range.pm | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/Nagios/Plugin/Range.pm b/lib/Nagios/Plugin/Range.pm index dbb637c..3828d1a 100644 --- a/lib/Nagios/Plugin/Range.pm +++ b/lib/Nagios/Plugin/Range.pm | |||
@@ -4,7 +4,12 @@ use 5.006; | |||
4 | 4 | ||
5 | use strict; | 5 | use strict; |
6 | use warnings; | 6 | use warnings; |
7 | |||
7 | use Carp; | 8 | use Carp; |
9 | use base qw(Class::Accessor::Fast); | ||
10 | __PACKAGE__->mk_accessors( | ||
11 | qw(start end start_infinity end_infinity alert_on) | ||
12 | ); | ||
8 | 13 | ||
9 | use Nagios::Plugin::Functions; | 14 | use Nagios::Plugin::Functions; |
10 | our ($VERSION) = $Nagios::Plugin::Functions::VERSION; | 15 | our ($VERSION) = $Nagios::Plugin::Functions::VERSION; |
@@ -12,15 +17,7 @@ our ($VERSION) = $Nagios::Plugin::Functions::VERSION; | |||
12 | use overload | 17 | use overload |
13 | '""' => sub { shift->_stringify }; | 18 | '""' => sub { shift->_stringify }; |
14 | 19 | ||
15 | use Class::Struct; | 20 | # alert_on constants (undef == range not set) |
16 | struct "Nagios::Plugin::Range" => { | ||
17 | start => '$', | ||
18 | end => '$', | ||
19 | start_infinity => '$', # TRUE / FALSE | ||
20 | end_infinity => '$', # TRUE / FALSE | ||
21 | alert_on => '$', # OUTSIDE 0, INSIDE 1, not defined == range not set | ||
22 | }; | ||
23 | |||
24 | use constant OUTSIDE => 0; | 21 | use constant OUTSIDE => 0; |
25 | use constant INSIDE => 1; | 22 | use constant INSIDE => 1; |
26 | 23 | ||
@@ -119,7 +116,14 @@ sub check_range { | |||
119 | } | 116 | } |
120 | } | 117 | } |
121 | 118 | ||
119 | # Constructor - map args to hashref for SUPER | ||
120 | sub new | ||
121 | { | ||
122 | shift->SUPER::new({ @_ }); | ||
123 | } | ||
124 | |||
122 | 1; | 125 | 1; |
126 | |||
123 | __END__ | 127 | __END__ |
124 | 128 | ||
125 | =head1 NAME | 129 | =head1 NAME |
@@ -135,7 +139,7 @@ Nagios::Plugin::Range - class for handling Nagios::Plugin range data. | |||
135 | $r = Nagios::Plugin::Range->new; | 139 | $r = Nagios::Plugin::Range->new; |
136 | 140 | ||
137 | # Instantiate by parsing a standard nagios range string | 141 | # Instantiate by parsing a standard nagios range string |
138 | $r = Nagios::Plugin::Range->parse_range_string; | 142 | $r = Nagios::Plugin::Range->parse_range_string( $range_str ); |
139 | 143 | ||
140 | # Returns true if the range is defined/non-empty | 144 | # Returns true if the range is defined/non-empty |
141 | $r->is_set; | 145 | $r->is_set; |