diff options
author | Tobi Oetiker <tobi@oetiker.ch> | 2008-06-04 23:08:59 +0200 |
---|---|---|
committer | Tobi Oetiker <tobi@oetiker.ch> | 2008-06-04 23:08:59 +0200 |
commit | 4940f51d54f1f4b994c02138defbcd8ff36a95ec (patch) | |
tree | 95f567b5d3b902e5ce181be421bb8e4b6c206118 /qooxdoo/source/perl/Qooxdoo/Services | |
parent | 1ede2f2620e6d40f0cadc2b196324e9de9bcd1ce (diff) | |
download | smokeping-4940f51d54f1f4b994c02138defbcd8ff36a95ec.tar.gz smokeping-4940f51d54f1f4b994c02138defbcd8ff36a95ec.tar.xz |
converted everything to traceroute propper ... much better
Diffstat (limited to 'qooxdoo/source/perl/Qooxdoo/Services')
-rw-r--r-- | qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm b/qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm index 6b1b746..6c04778 100644 --- a/qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm +++ b/qooxdoo/source/perl/Qooxdoo/Services/Mtr.pm @@ -85,7 +85,7 @@ sub method_run_mtr # this is especially important when running with speedy of fastcgi waitpid($handle,WNOHANG); $again = kill(0, $handle); - usleep(1000*200) if $rounds; + usleep(1000*300) if $rounds; # print STDERR "$again, $handle, $size, $point\n"; $rounds ++; } while ($again and $point >= $size); @@ -93,20 +93,26 @@ sub method_run_mtr my @array; while (<$fh>){ waitpid($handle,WNOHANG); + /^traceroute to/ && next; 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; + if (/^\s*(\d+)\s+(\S+)\s+\((\S+?)\)\s+(\S+)\s+ms/){ + my ($hop,$host,$ip,$value) = ($1,$2,$3,$4); + $value = undef unless $value =~ /^\d+(\.\d+)?$/; + push @array, [$hop,$host,$ip,$value]; + $point = tell($fh); + } + elsif (/^\s*(\d+)\s+\*/){ + push @array, [$1,undef,undef,undef]; + $point = tell($fh); + } + else { + $error->set_error(107,"ERROR: $_. See $data for more information."); + return $error; + } }; close $fh; unlink $data unless $again; |