[smokeping-users] [RFC] patch for the 0.0.0.1 problem

Tobias Oetiker tobi at oetiker.ch
Fri Oct 12 08:30:01 CEST 2007


Folks,

I have removed all occurances of 0.0.0.1 from smokeping. Can
someone who got bitten by this please see if the attached patch
helps ?

The idea is to not actually do any network connection but work from
the programs error output.

cheers
tobi

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten
http://it.oetiker.ch tobi at oetiker.ch ++41 62 213 9902
-------------- next part --------------
Index: lib/Smokeping/probes/Curl.pm
===================================================================
--- lib/Smokeping/probes/Curl.pm	(revision 838)
+++ lib/Smokeping/probes/Curl.pm	(working copy)
@@ -202,16 +202,14 @@
 
 	my $arghashref = $self->features;
 	my %arghash = %$arghashref;
-
+        my $curl_man = `$bin --manual`;
 	for my $feature (keys %arghash) {
-		system("$bin $arghash{$feature} 1 0.0.0.1 >/dev/null 2>&1");
-		if ($? == 2) {
-			push @unsupported, $feature;
-			$self->do_log("Note: your curl doesn't support the $feature feature (option $arghash{$feature}), disabling it");
-		}
+		next if $curl_man =~ /\Q$arghash{$feature}/;
+        	push @unsupported, $feature;
+		$self->do_log("Note: your curl doesn't support the $feature feature (option $arghash{$feature}), disabling it");
 	}
 	map { delete $arghashref->{$_} } @unsupported;
-	if (`$bin -o /dev/null -w '<%{time_redirect}>\n' 0.0.0.1 2>&1` =~ /^<>/m) {
+	if ($curl_man !~ /\stime_redirect\s/) {
 		$self->do_log("Note: your curl doesn't support the 'time_redirect' output variable; 'include_redirects' will not function.");
 	}
 	return;
Index: lib/Smokeping/probes/EchoPingChargen.pm
===================================================================
--- lib/Smokeping/probes/EchoPingChargen.pm	(revision 838)
+++ lib/Smokeping/probes/EchoPingChargen.pm	(working copy)
@@ -46,7 +46,7 @@
 	my $self = shift;
 	my $bin = $self->{properties}{binary};
 	croak("Your echoping binary doesn't support CHARGEN")
-		if `$bin -c 2>&1 0.0.0.1` =~ /(usage|not compiled|invalid option)/i;
+		if `$bin -c 2>&1` !~ /^Usage/i;
 	$self->SUPER::test_usage;
 	return;
 }
Index: lib/Smokeping/probes/EchoPing.pm
===================================================================
--- lib/Smokeping/probes/EchoPing.pm	(revision 838)
+++ lib/Smokeping/probes/EchoPing.pm	(working copy)
@@ -88,15 +88,16 @@
 
 	my $arghashref = $self->features;
 	my %arghash = %$arghashref;
-
 	for my $feature (keys %arghash) {
-		if (`$bin $arghash{$feature} 1 0.0.0.1 2>&1` =~ /invalid option|usage/i) {
+                # when the option is invalid, then echoping would
+                # complain. if it is valid, then it will just display
+                # the usage message.
+		if (`$bin $arghash{$feature} 2>&1` !~ /^Usage/i) {
 			push @unsupported, $feature;
 			$self->do_log("Note: your echoping doesn't support the $feature feature (option $arghash{$feature}), disabling it");
 		}
 	}
 	map { delete $arghashref->{$_} } @unsupported;
-
 	return;
 }
 
Index: lib/Smokeping/probes/EchoPingSmtp.pm
===================================================================
--- lib/Smokeping/probes/EchoPingSmtp.pm	(revision 838)
+++ lib/Smokeping/probes/EchoPingSmtp.pm	(working copy)
@@ -54,7 +54,7 @@
 	my $self = shift;
 	my $bin = $self->{properties}{binary};
 	croak("Your echoping binary doesn't support SMTP")
-		if `$bin -S 0.0.0.1 2>&1` =~ /(not compiled|invalid option|usage)/i;
+		if `$bin -S  2>&1`  !~ /^Usage/;
 	$self->SUPER::test_usage;
 	return;
 }
Index: lib/Smokeping/probes/EchoPingDiscard.pm
===================================================================
--- lib/Smokeping/probes/EchoPingDiscard.pm	(revision 838)
+++ lib/Smokeping/probes/EchoPingDiscard.pm	(working copy)
@@ -46,7 +46,7 @@
 	my $self = shift;
 	my $bin = $self->{properties}{binary};
 	croak("Your echoping binary doesn't support DISCARD")
-		if `$bin -d 0.0.0.1 2>&1` =~ /(not compiled|invalid option|usage)/i;
+		if `$bin -d  2>&1`  !~ /^Usage/i;
 	$self->SUPER::test_usage;
 	return;
 }
Index: lib/Smokeping/probes/EchoPingHttp.pm
===================================================================
--- lib/Smokeping/probes/EchoPingHttp.pm	(revision 838)
+++ lib/Smokeping/probes/EchoPingHttp.pm	(working copy)
@@ -88,13 +88,13 @@
 	my $self = shift;
 	my $bin = $self->{properties}{binary};
 	croak("Your echoping binary doesn't support HTTP")
-		if `$bin -h / 0.0.0.1 2>&1` =~ /(invalid option|not compiled|usage)/i;
-	if (`$bin -a -h / 0.0.0.1 2>&1` =~ /(invalid option|not compiled|usage)/i) {
+		if `$bin -h /  2>&1`  !~ /^Usage/;
+	if (`$bin -a -h /  2>&1`  !~ /^Usage/) {
 		carp("Note: your echoping binary doesn't support revalidating (-a), disabling it");
 		$self->{_disabled}{a} = undef;
 	}
 
-	if (`$bin -A -h / 0.0.0.1 2>&1` =~ /(invalid option|not compiled|usage)/i) {
+	if (`$bin -A -h /  2>&1`  !~ /^Usage/) {
 		carp("Note: your echoping binary doesn't support ignoring cache (-A), disabling it");
 		$self->{_disabled}{A} = undef;
 	}


More information about the smokeping-users mailing list