Need shell script help

FreshPrince

Diamond Member
Dec 6, 2001
8,361
1
0
I need a script that'll check the health of a website located in "Location A". By either ping or a higher level by pulling up a text file containing certain text. If these conditions are met, the website is considered healthy. If it's not healthy, check a known website to ensure internet connectivity is up. If so, update dns zone file to point website to another ip address in "location B". Else it thinks the problem is itself and does nothing.

This is a simple plan for DNS failover I've come up, but I'm not a good shell script writer. Someone help me out.

I'll be doing the health checks from DNS servers running redhat 9 in "Location C".

Thanks!

-FP
 

Need4Speed

Diamond Member
Dec 27, 1999
5,383
0
0
here is enough to get you started...you can add your dns updating

#!/bin/bash
host_a="www"
host_b="mail"

if ping -c 1 $host_a >& /dev/null ; then
echo "$host_a is alive, all is well"
else
echo "$host_a is dead, check $host_b"
if ping -c 1 $host_b >& /dev/null ; then
echo "$host_b is alive, must be problem with $host_a"
else
echo "$host_a and $host_b are both dead, connection problem"
fi
fi

EDIT: damn reply box wont format correctly, but you get the idea