I am trying to write a monitoring program that will send an email if it cannot do a tnsping to a database. I have a number of database names that I want to run the command on. How can I write a script to do this. I know I can write an if statement for each var but I think there should be an easier \ cleaner way. For example:
-----------------------------------------------------------------------------
DB1=test
DB_VAR=`tnsping $DB1 | grep OK | awk -F ' ' '{print $1}'`
if [ DB_VAR =! "OK" ]; then
echo "Something is messed up with the database" | mail
blah@blah.com
fi
How can I do this with a number of different database names?