Page 1 of 1

Contributing keepalive script + question

Posted: Sat Nov 20, 2010 8:50 pm
by orange
Hi,

using Gargoyle (currently 1.3.7) for quite some time as a Wireless bridge connected to my cellar buildserver, I'm encountering "Destination Host Unreachable" messages after some hours. I'm not sure yet if it's a lockup or just a lost connection but for experimenting I wrote a keepalive script worth sharing from my perspective, i.e. I hope someone else using Gargoyle as a Wireless bridge may benefit from it.

Put the following to /bin/keepalive

Code: Select all

#!/bin/sh
rm -f /tmp/keepalive
ping -c 3 $(uci get network.lan.gateway) > /tmp/keepalive 2> /dev/null
state=$?
percent=$(awk '/packets/ {split($7, z, "%"); print z[1]}' /tmp/keepalive)
if [ $state -ne 0 ] || [ $percent -eq 100 ]; then
	logger -p user.info -t keepalive[$$] "renewing connection to $(uci get network.lan.gateway)"
	ifup lan
	/sbin/wifi
fi
Certainly chmod +x it and introduce a cronjob

Code: Select all

root@Gargoyle:~# echo "*/5 * * * * /bin/keepalive >> /etc/crontabs/root
root@Gargoyle:~# /etc/init.d/cron restart
The keepalive script will verify the gateway connection every 5 minutes and renew it if required. This should solve described issues (assumed it isn't a lockup of the device in the end).

Also (+ question in my topic's subject), while looking at /etc/crontabs/root, I'm wondering why data is written to flash memory every 4 hours? Isn't that a rather bad idea from a flash memory wear-out perspective, i.e. wouldn't /tmp be a better target for it?
0 0,4,8,12,16,20 * * * date -u +"%Y.%m.%d-%H:%M:%S" >/usr/data/time_backup
best,
orange

Re: Contributing keepalive script + question

Posted: Mon Nov 22, 2010 4:52 am
by pbix
Regarding flash erase issues. Not sure which flash chip your router has but I looked at the M25P64 which probably is close. It has 125 sectors each with "More than 100000" erase cycles. Lets say 50 of those are used by the image so 75 remain for jffs.

If the write size was 64kB then the math is 75*100000/8 writes per day)/365 days ~ 2500 years.