summaryrefslogtreecommitdiffstats
path: root/qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm
diff options
context:
space:
mode:
authorTobi Oetiker <tobi@oetiker.ch>2008-06-04 00:46:38 +0200
committerTobi Oetiker <tobi@oetiker.ch>2008-06-04 00:46:38 +0200
commit1ede2f2620e6d40f0cadc2b196324e9de9bcd1ce (patch)
treec02b14d5bca780abd7977754a38ba392b6a0f44b /qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm
parent9c59d668c6d0611f1ea611ca0e9ea5a5954eaa20 (diff)
downloadsmokeping-1ede2f2620e6d40f0cadc2b196324e9de9bcd1ce.tar.gz
smokeping-1ede2f2620e6d40f0cadc2b196324e9de9bcd1ce.tar.xz
prepping for traceroute switch
Diffstat (limited to 'qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm')
-rw-r--r--qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm26
1 files changed, 15 insertions, 11 deletions
diff --git a/qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm b/qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm
index 6aead46..6b1b746 100644
--- a/qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm
+++ b/qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm
@@ -9,7 +9,9 @@ sub GetAccessibility {
sub launch {
my $error = shift;
- $SIG{CHLD} = \&REAPER;
+ my $rounds = shift;
+ my $delay = shift;
+ my $host = shift;
defined(my $pid = fork) or do { $error->set_error(101,"Can't fork: $!");return $error};
if ($pid){
open my $x, ">/tmp/mtr_session.$pid" or do {
@@ -25,7 +27,10 @@ sub launch {
open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
setsid or die "Can't start a new session: $!";
open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
- exec @_;
+ for (my $i = 0; $i<$rounds;$i++){
+ system "traceroute","-I","-q","1",$host;
+ sleep $delay;
+ }
}
sub get_number {
@@ -64,7 +69,7 @@ sub method_run_mtr
return $delay if ref $delay;
my $rounds = get_number($error,$arg->{rounds});
return $rounds if ref $rounds;
- $handle = launch ($error,"mtr","-4","--raw","--report-cycles=$rounds","--interval=$delay",$arg->{host});
+ $handle = launch ($error,$rounds,$delay,$arg->{host});
$point = 0;
}
return $point if ref $point;
@@ -87,22 +92,21 @@ sub method_run_mtr
if (seek $fh, $point,0){
my @array;
while (<$fh>){
- if (not /^[a-z]\s/){
- waitpid($handle,WNOHANG);
- if (/Name or service not known/){
- $error->set_error(108,"Unknown hostname.");
- return $error;
- }
+ waitpid($handle,WNOHANG);
+ if (/unknown host/){
+ $error->set_error(108,"Unknown hostname.");
+ return $error;
+ }
else {
$error->set_error(107,"ERROR: $_. See $data for more information.");
return $error;
}
}
last unless /\n$/; # stop when we find an incomplete line
+ /^\s*(\d+)\s+(\S+)\s+\((\S+?)\)\s+(\S+)\s+ms/ or next;
+ push @array, [$1,$2,$3,$4];
$point = tell($fh);
chomp;
- my @line = split (/\s+/,$_);
- push @array,\@line;
};
close $fh;
unlink $data unless $again;