Koozali.org: home of the SME Server

Legacy Forums => Experienced User Forum => Topic started by: Luke Drumm on June 12, 2001, 09:10:32 AM

Title: A poor mans bouncer...
Post by: Luke Drumm on June 12, 2001, 09:10:32 AM
Howdy,

Despite a numerous amount of complete rebuilds my Telstra connection is still very shaky thus I present two small scripts for those who a similar fate:

---- 'bounce' script start -------
ifdown eth1
ifup eth1
service bpalogin restart
---- 'bounce' script end -------


---- 'sexyduck.p' script start -------
#!/usr/bin/perl -w

use strict;

while (1==1) {
  sleep 10;
  print 'Testing... ';
  my (@pong) = ping -nv -c 2 144.132.128.1 1>&1 2>/dev/null;
  my ($flag)=0;

  foreach my $pongline (@pong) {
    if (index($pongline,' 100% packet loss')>0) {
      $flag=1;
      #print 'Yes:'.$pongline;
    } else {
      #print 'No :'.$pongline;
    }
  }

  if ($flag == 0) {
    print "Passed\n";
  } else {
    /root/bounce;
    print "Finished\n";
  }
}
---- 'sexyduck.p' script end -------

The address that I choose to ping for this is (I assume) my nearest router. If you perform a traceroute to some popular site (eg. www.yahoo.com) you should be able to spot the next node up from your machine.

Regards,
Luke