2013-11-14 23:11:16 -07:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
# wait for the watchdog file to appear
|
|
|
|
while(not -e "/tmp/olsrd.watchdog") { sleep 15 }
|
|
|
|
|
2014-11-03 20:59:34 -07:00
|
|
|
$failcount = 0;
|
|
|
|
$last_olsrstamp = 0;
|
|
|
|
|
2013-11-14 23:11:16 -07:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
chomp ($olsr = `cat /tmp/olsrd.watchdog`);
|
|
|
|
|
2014-11-03 20:59:34 -07:00
|
|
|
if ( $olsr && $olsr ne $last_olsrstamp ){
|
|
|
|
$failcount = 0;
|
|
|
|
} else {
|
|
|
|
$failcount += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( $failcount >= 3 )
|
2013-11-14 23:11:16 -07:00
|
|
|
{
|
|
|
|
($uptime) = `cat /proc/uptime` =~ /^(\d+)/;
|
|
|
|
$date = `date`;
|
|
|
|
system qq(echo -n "$uptime $date" >> /tmp/olsrd.log);
|
|
|
|
system "/etc/init.d/olsrd restart";
|
|
|
|
}
|
|
|
|
|
2014-11-03 20:59:34 -07:00
|
|
|
$last_olsrstamp = $olsr;
|
|
|
|
|
|
|
|
sleep 10;
|
2013-11-14 23:11:16 -07:00
|
|
|
}
|