|
Network Services Reboot Script for Network Cards using the Tulip Driver
Some of my servers use the Netgear 310TX card (which is approved by Redhat btw),
and have a sort of nasty habit. It seems that whenever they get unplugged from
the network, the card (or OS) doesn't then detect that the card is reconnected
and so the link remains dead.
Needless to say, this can render a remote box rather useless and force a call
to the webhotel folks for the "... yes, I know it's Linux, and it never needs
a reboot, but..." call!
I found this little script called from cron seems to take care of the problem
of never being able to get the server responding.
You can of course adjust the cron interval to suit your needs. Be sure to set
your $GWADDR to your gateway address.
If your gateway address changes- don't forget to change it in the script or
you will get bounced very X number of minutes. ;-)
#------------SCRIPT-STARTS-UNDER-THIS-LINE-----------#
#!/usr/bin/perl
#netboot: tests to see if gateway is unreachable and
#if so, restart networking. Useful for tulip based
#cards. Call from crontab
#set $GWADDR to your gateway address.
$GWADDR="192.192.192.192";
$result=`/bin/ping -c 2 -w 3 $GWADDR 2>/dev/null`;
chop $result;
$reslen=length($result);
if ($reslen < 10 || $result=~/100\% packet loss/i){
system("/etc/init.d/network restart");
}
#------------SCRIPT-ENDS-HERE------------------------#
#----------------- put this line in /etc/crontab
#0,10,20,30,40,50 * * * * root /path_to/netboot
|