2 simple script for restarting dead program and reconnect wan

They are very simple scripts which i understand (used pieces found in existing scripts on internet), i´m sure most of you think is pretty basic , but since i did´t find them already on this forum i thought i share´m with you.

i have a r7800(since 2days back) currently running
pingcheck, if ping.sunet.se is down it will restart my wan interface

x=`ping -c1 ping.sunet.se 2>&1 | grep bad`
if [ ! "$x" = "" ]; then
        echo "It's down!! Attempting to restart."
        date >> /tmp/ping-down
        ifdown wan
sleep 1
        ifup wan

and my script to verify if collectd is running (been dying a couple of time, not sure why..yet)


ps  | grep collectd | grep -v grep > /dev/null

if [ $? != 0 ]
        /bin/date >> /tmp/collectd-crash
        /etc/init.d/collectd start

Just stick´m in crontab with intervall of your choice