summaryrefslogtreecommitdiffstats
path: root/lib/Nagios/Plugin/Range.pm
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-06-15 09:11:54 +0000
committerTon Voon <tonvoon@users.sourceforge.net>2006-06-15 09:11:54 +0000
commitf948ceecba9b5f6cb0aef9aae6f6be18ba6feffe (patch)
tree687e8c72f89ae9cced849754e362f1cde19ae745 /lib/Nagios/Plugin/Range.pm
parente736a3c2b0a62707f12cf66fbb65ef23eeb01dd6 (diff)
downloadmonitoring-plugin-perl-f948ceecba9b5f6cb0aef9aae6f6be18ba6feffe.tar.gz
is_set method to see if a range has been set
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1429 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/Nagios/Plugin/Range.pm')
-rw-r--r--lib/Nagios/Plugin/Range.pm8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Nagios/Plugin/Range.pm b/lib/Nagios/Plugin/Range.pm
index 3d6f613..c03001a 100644
--- a/lib/Nagios/Plugin/Range.pm
+++ b/lib/Nagios/Plugin/Range.pm
@@ -14,7 +14,7 @@ struct "Nagios::Plugin::Range" => {
14 end => '$', 14 end => '$',
15 start_infinity => '$', # TRUE / FALSE 15 start_infinity => '$', # TRUE / FALSE
16 end_infinity => '$', # TRUE / FALSE 16 end_infinity => '$', # TRUE / FALSE
17 alert_on => '$', # OUTSIDE 0, INSIDE 1 17 alert_on => '$', # OUTSIDE 0, INSIDE 1, not defined == range not set
18 }; 18 };
19 19
20my $outside = 0; 20my $outside = 0;
@@ -22,11 +22,17 @@ my $inside = 1;
22 22
23sub stringify { 23sub stringify {
24 my $self = shift; 24 my $self = shift;
25 return "" unless $self->is_set;
25 return (($self->alert_on) ? "@" : "") . 26 return (($self->alert_on) ? "@" : "") .
26 (($self->start_infinity == 1) ? "~:" : (($self->start == 0)?"":$self->start.":")) . 27 (($self->start_infinity == 1) ? "~:" : (($self->start == 0)?"":$self->start.":")) .
27 (($self->end_infinity == 1) ? "" : $self->end); 28 (($self->end_infinity == 1) ? "" : $self->end);
28} 29}
29 30
31sub is_set {
32 my $self = shift;
33 (! defined $self->alert_on) ? 0 : 1;
34}
35
30sub set_range_start { 36sub set_range_start {
31 my ($self, $value) = @_; 37 my ($self, $value) = @_;
32 $self->start($value+0); # Force scalar into number 38 $self->start($value+0); # Force scalar into number