aredn/files/usr/local/bin/olsrd-watchdog

32 lines
550 B
Plaintext
Raw Normal View History

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