Crappy Wireless Device – Auto Reset

I’ve got a piece of crap wireless network device. It disconnects or the server part just locks up, or dies, or I have no idea, but it stops working. I am not fond of this behavior. It seems to work pretty well after it’s reset. It could be any misbehaving device like a modem, router, wireless cam, network security camera, bridge, or repeater.

This runs on my linux box running ubuntu server. It runs the job every 5 minutes, pings the crap device and the router. If the router has reset itself (very crappy unreliable century link DSL service) it makes note of this. The router usually comes back within 5 minutes.

If the device has stopped responding to ping and the router is up, it uses my CM11a X10 interface with heyu to turn off the appliance module the crap device is plugged in to. It’s not nice on the crap device, but beating on its power supply is a fair punishment for just stopping work after about a week.

raging@watchdog:~$ crontab -l

# m h dom mon dow command
*/5 * * * * /usr/bin/perl /usr/local/bin/ >> "/tmp/pingtest.log" 2>&1

raging@watchdog:/usr/local/bin$ cat

use Net::Ping;

$device = "a5";
$host = "";
$router = "";

$kill_it = "/usr/local/bin/heyu off $device";
$start_it = "/usr/local/bin/heyu on $device";

$p = Net::Ping->new();
$pr = Net::Ping->new();
($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
printf "%02d/%02d/%4dt%02d:%02d:%02dt", $month + 1, $dayOfMonth, $yearOffset + 1900, $hour, $minute, $second;

if ( !($pr->ping($router)) ){
print "$router down.n";

if ( $p->ping($host) ){
print "$host is alive.n";
} else {
if ( $p->ping($host) ){
print "$host is sort of alive.n";
} else {
print "$host is dead.n";
open (LOG, ">>/home/raging/cameralog.txt");
($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
printf LOG "%02d/%02d/%4dt%02d:%02d:%02d", $month + 1, $dayOfMonth, $yearOffset + 1900, $hour, $minute, $second;
system "$kill_it";
system "$start_it";
print LOG "t$host reset.n";
close (LOG);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: