[Nagiosplug-checkins] Nagios-Plugin/lib/Nagios/Plugin Range.pm, 1.1.1.1, 1.2 Threshold.pm, 1.1.1.1, 1.2

Ton Voon tonvoon at users.sourceforge.net
Thu Jun 15 11:11:56 CEST 2006


Update of /cvsroot/nagiosplug/Nagios-Plugin/lib/Nagios/Plugin
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3484/lib/Nagios/Plugin

Modified Files:
	Range.pm Threshold.pm 
Log Message:
is_set method to see if a range has been set


Index: Threshold.pm
===================================================================
RCS file: /cvsroot/nagiosplug/Nagios-Plugin/lib/Nagios/Plugin/Threshold.pm,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Threshold.pm	8 Jun 2006 12:27:44 -0000	1.1.1.1
+++ Threshold.pm	15 Jun 2006 09:11:54 -0000	1.2
@@ -16,7 +16,7 @@
 
 sub set_thresholds {
 	my ($class, %args) = @_;
-	my $t = $class->new;
+	my $t = $class->new( warning => Nagios::Plugin::Range->new, critical => Nagios::Plugin::Range->new );
 	if (defined $args{warning}) {
 		my $r = Nagios::Plugin::Range->parse_range_string($args{warning});
 		if (defined $r) {
@@ -44,12 +44,12 @@
 
 sub get_status {
 	my ($self, $value) = @_;
-	if ($self->critical) {
+	if ($self->critical->is_set) {
 		if ($self->critical->check_range($value) == 1) {
 			return $ERRORS{CRITICAL};
 		}
 	}
-	if ($self->warning) {
+	if ($self->warning->is_set) {
 		if ($self->warning->check_range($value) == 1) {
 			return $ERRORS{WARNING};
 		}

Index: Range.pm
===================================================================
RCS file: /cvsroot/nagiosplug/Nagios-Plugin/lib/Nagios/Plugin/Range.pm,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Range.pm	8 Jun 2006 12:27:44 -0000	1.1.1.1
+++ Range.pm	15 Jun 2006 09:11:54 -0000	1.2
@@ -14,7 +14,7 @@
 	end => '$',
 	start_infinity => '$',	# TRUE / FALSE
 	end_infinity => '$',	# TRUE / FALSE
-	alert_on => '$',	# OUTSIDE 0, INSIDE 1
+	alert_on => '$',	# OUTSIDE 0, INSIDE 1, not defined == range not set
 	};
 
 my $outside = 0;
@@ -22,11 +22,17 @@
 
 sub stringify {
 	my $self = shift;
+	return "" unless $self->is_set;
 	return (($self->alert_on) ? "@" : "") .
 		(($self->start_infinity == 1) ? "~:" : (($self->start == 0)?"":$self->start.":")) . 
 		(($self->end_infinity == 1) ? "" : $self->end);
 }
 
+sub is_set {
+	my $self = shift;
+	(! defined $self->alert_on) ? 0 : 1;
+}
+
 sub set_range_start {
 	my ($self, $value) = @_;
 	$self->start($value+0);	# Force scalar into number





More information about the Commits mailing list