I've found that my ActionTec DSL modem locks up quite frequently, and
the network halts. It has become quite irritating to constantly have
to cycle power on the modem / router.
I wrote a script that will reset the DSL modem and log the event upon
detecting a dead connection. I have this script set up to run every
minute via a cron job.
Currently the script runs on Red Hat 9 out of the box, and probably
other distros. You'll need to edit the variables at the top. Be sure
to replace the "buddy_sites" variable with hosts that actually respond
to pings. Here is the script in anyone is interested:
#!/usr/bin/expect --
set router_addy 192.168.2.1
set username admin
set password mypassword
set buddy_sites "\
www.csun.edu\
chtm.unm.edu\
"
set logfilename /var/log/cron
proc site_dead {site}\
{
spawn ping -c1 -q $site
set rtndata 0
expect \
{
"100% packet loss" {set rtndata 1}
" 0% packet loss" {set rtndata 0}
}
return $rtndata
}
proc my_net_is_a_bastard {sites}\
{
set rtndata 1
foreach site $sites\
{
if {![site_dead $site]}\
{
set rtndata 0
break
}
}
return $rtndata
}
proc reboot_actiontec {addy user pass}\
{
spawn telnet $addy
expect "Login:" {send "$user\r"}
expect "Password:" {send "$pass\r"}
expect -re "-->" {send "system restart\r"}
}
proc log_incident {logfilename selfname}\
{
set log [open $logfilename a]
puts $log "[exec date "+%b %e %T"] [exec hostname -s]\
$selfname: DSL connection reset"
close $log
}
if {[my_net_is_a_bastard $buddy_sites]}\
{
reboot_actiontec $router_addy $username $password
log_incident $logfilename $argv0
} else {
puts "my network rocks!"
}