Forums.ATC.no

Teknisk => Generelt teknisk => Emne startet av: ATC på 06. Oktober 2010, 08:40 am

Tittel: Net::Ping::External does not support timeout option on linux
Skrevet av: ATC06. Oktober 2010, 08:40 am
The Perl module Net::Ping::External supports a 'timeout' option but for some reason this is not implemented on the linux platform. A bug report for this was submitted in 2004 and still the auther has not patched the module. Further, it seems impossible to log into the bug tracker to post a solution.
Tittel: [Solved] Net::Ping::External does not support timeout option on linux
Skrevet av: ATC06. Oktober 2010, 08:40 am
Edit the relevant file, e.g.

/usr/lib/perl5/site_perl/5.8.8/Net/Ping/External.pm

Change this

sub _ping_linux {
  my %args = @_;
  my $command;
#for next version
  if (-e '/etc/redhat-release' || -e '/etc/SuSE-release') {
    $command = "ping -c $args{count} -s $args{size} $args{host}";
  } else {
    $command = "ping -c $args{count} $args{host}";
  }
  return _ping_system($command, 0);
}

Into this

sub _ping_linux {
  my %args = @_;
  my $command;
#for next version
  if (-e '/etc/redhat-release' || -e '/etc/SuSE-release') {
    $command = "ping -c $args{count} -s $args{size} -w $args{timeout} $args{host}";
  } else {
    $command = "ping -c $args{count} $args{host}";
  }
  return _ping_system($command, 0);
}

by inserting "-w $args{timeout}"