summaryrefslogtreecommitdiffstats
path: root/lib/Nagios/Plugin/Range.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Nagios/Plugin/Range.pm')
-rw-r--r--lib/Nagios/Plugin/Range.pm24
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
5use strict; 5use strict;
6use warnings; 6use warnings;
7
7use Carp; 8use Carp;
9use base qw(Class::Accessor::Fast);
10__PACKAGE__->mk_accessors(
11 qw(start end start_infinity end_infinity alert_on)
12);
8 13
9use Nagios::Plugin::Functions; 14use Nagios::Plugin::Functions;
10our ($VERSION) = $Nagios::Plugin::Functions::VERSION; 15our ($VERSION) = $Nagios::Plugin::Functions::VERSION;
@@ -12,15 +17,7 @@ our ($VERSION) = $Nagios::Plugin::Functions::VERSION;
12use overload 17use overload
13 '""' => sub { shift->_stringify }; 18 '""' => sub { shift->_stringify };
14 19
15use Class::Struct; 20# alert_on constants (undef == range not set)
16struct "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
24use constant OUTSIDE => 0; 21use constant OUTSIDE => 0;
25use constant INSIDE => 1; 22use 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
120sub new
121{
122 shift->SUPER::new({ @_ });
123}
124
1221; 1251;
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;