#! /usr/bin/perl -w # (c) 2000, Wouter van Wijk # begin sub pptp { `killall pptp`; } sub testping { $maxping = "500"; $pingoutput =`ping -c 5 194.109.9.99`; # Split output of ping command @pingsplit = split "/", $pingoutput; # test how many packets arrived # rude, but functional for me pptp() if $pingoutput =~ /100%/; pptp() if $pingoutput =~ /80%/; pptp() if $pingoutput =~ /60%/; #error: unknown host pptp() if $pingoutput =~ /unknown host/; pptp() if $pingoutput =~ /unreachable/; # 3th pingsplit is the average pingtime (as for the version in Redhat 6.2) # print $pingsplit[3]; # debug print # print "\n"; # wait 1 minute sleep 60; #double check if ($pingsplit[3] > $maxping) { $pingoutput =`ping -c 5 194.109.6.66`; # test how many packets arrived # rude, but functional for me pptp() if $pingoutput =~ /100%/; pptp() if $pingoutput =~ /80%/; pptp() if $pingoutput =~ /60%/; pptp() if $pingoutput =~ /40%/; pptp() if $pingoutput =~ /unknown host/; pptp() if $pingoutput =~ /unreachable/; # Split output of ping command @pingsplit = split "/", $pingoutput; print $pingsplit[3] if ($pingsplit[3] > $maxping); pptp() if ($pingsplit[3] > $maxping); } # if } # sub # loop while (1) { testping () }