Contributing keepalive script + question

Discuss the technical details of Gargoyle and ongoing development

Moderator: Moderators

Post Reply
User avatar
orange
Posts: 1
Joined: Sat Nov 20, 2010 8:13 pm
Location: 49.51N, 08.39E
Contact:

Contributing keepalive script + question

Post 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
7x La Fonera 2100
running bleeding edge openwrt kamikaze
#fonerahacks on irc.freenode.net
http://piranha.pwnz.org

pbix
Developer
Posts: 1373
Joined: Fri Aug 21, 2009 5:09 pm

Re: Contributing keepalive script + question

Post 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.
Linksys WRT1900ACv2
Netgear WNDR3700v2
TP Link 1043ND v3
TP-Link TL-WDR3600 v1
Buffalo WZR-HP-G300NH2
WRT54G-TM

Post Reply