-
shell script to check remote db is up ?
Hi anyone has shell script to check the remote db is up or not ?
If all the login username and password are unknown... will it be too difficult to put the check in script ?
Your contribution is very much appreciated. Thank You.
-
Hi
Well the only realy way to check wheather the database is up or not would be to from a shell script taht can actually login into the databse and do somethin like seelect sysdate from dual;..other methods like checking for ps -ef |grep smon and might be useful..but what if the database is just mounted and not open..your pager would ring anyway :-)
regards
Hrishy
-
log in into that server then check weather any oracle background process is running or not
U can check by using
ps -aef | grep dbwr
-
Code:
#!/bin/ksh
#DIR_EJE=${HOME_EXP}/shell
DIR_EJE=/home/oracle7/admin/control-m/ORADISPONIBLE
#TNS_ADMIN=${DIR_EJE}
TNS_ADMIN=/home/oracle7/admin/control-m/TNS_ADMIN
OPCION=
TECLA=
ORACLE_HOME=/home/ttd/oracle/app/oracle/product/7.3.4
uso()
{
echo ""
printf "Elija una de las opciones posibles [1, 2, 3, 4]"
echo ""
}
continua()
{
echo ""
echo ""
echo "Pulsa una tecla para continuar ...........\c"
read TEC
}
menu()
{
clear
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
printf "\t\t\tElija una opcion:\n"
printf "\t\t\t=================\n"
echo ""
echo ""
printf "\t\t\t1. Disponibilidad bases de datos produccion\n"
echo ""
printf "\t\t\t2. Disponibilidad comunicaciones\n"
echo ""
printf "\t\t\t3. Disponibilidad Oracle Comunicaciones\n"
echo ""
printf "\t\t\t4. Salir\n"
echo ""
}
disponible()
{
echo ""
echo "Fecha de ejecucion del script : `date`"
echo ""
printf "\t\tB Datos\t\tDominio\t\t\tEstado\n"
printf "\t\t=======\t\t=======\t\t\t======\n"
printf "\n"
cat ${DIR_EJE}/bbdd.conf | grep -v "#" | while read dominio bbdd version
do
FICHERO_RESUL=${DIR_EJE}/dispon${bbdd}.txt
[[ -f $FICHERO_RESUL ]] && rm -f $FICHERO_RESUL
${DIR_EJE}/oradisponible ${bbdd}_${dominio} > $FICHERO_RESUL
estado=$?
printf "\t\t"${bbdd}"\t\t"%11s"\t\t\c" ${dominio}
if [ $estado -eq 0 ];then
msgestado=OK
else
if [ $estado -eq 1 ];then
msgestado=ERROR
else
msgestado=AVISO
fi
fi
printf $msgestado": "
cat $FICHERO_RESUL
[[ -f $FICHERO_RESUL ]] && rm -f $FICHERO_RESUL
done
}
tnsping()
{
echo ""
echo "Fecha de ejecucion del script : `date`"
echo ""
print "\t\tB Datos\t\tDominio\t\t\tEstado"
print "\t\t=======\t\t=======\t\t\t======"
print ""
cat ${DIR_EJE}/bbdd.conf | grep -v "#" | while read dominio bbdd version
do
FICHERO_RESUL=${DIR_EJE}/dispon${bbdd}.txt
[[ -f $FICHERO_RESUL ]] && rm -f $FICHERO_RESUL
${ORACLE_HOME}/bin/tnsping ${bbdd}_${dominio} > $FICHERO_RESUL
estado=$?
printf "\t\t"${bbdd}"\t\t"%11s"\t\t\c" ${dominio}
if [ $estado -eq 0 ];then
msgestado=OK
else
if [ $estado -eq 1 ];then
msgestado=ERROR
else
msgestado=AVISO
fi
fi
printf $msgestado": "
tail -1 $FICHERO_RESUL
[[ -f $FICHERO_RESUL ]] && rm -f $FICHERO_RESUL
done
}
comunicaciones()
{
echo ""
echo "Fecha de ejecucion del script : `date`"
echo ""
print "\t\tMaquina\t\t\tEstado"
print "\t\t=======\t\t\t======"
print ""
cat ${DIR_EJE}/bbdd.conf | grep -v "#"| cut -d' ' -f1 | uniq | while read dominio version
do
FICHERO_RESUL=${DIR_EJE}/dispon${bbdd}.txt
[[ -f $FICHERO_RESUL ]] && rm -f $FICHERO_RESUL
/usr/sbin/ping ${dominio} > $FICHERO_RESUL
estado=$?
print "\t\t"${dominio}"\t\t\c"
if [ $estado -eq 0 ];then
msgestado=OK
else
if [ $estado -eq 1 ];then
msgestado=ERROR
else
msgestado=AVISO
fi
fi
printf $msgestado": "
tail -1 $FICHERO_RESUL
[[ -f $FICHERO_RESUL ]] && rm -f $FICHERO_RESUL
done
}
# MAIN
while [ 1 ]
do
menu
echo "\t\t\tElija una opcion: \c"
read OPCION
case ${OPCION} in
1) disponible
continua
;;
2) comunicaciones
continua
;;
3) tnsping
continua
;;
4) echo ""
exit 0
;;
[a-z,A-Z]) uso
continua
;;
*)
;;
esac
done
exit 0
-
Thus we learn not only shell scripting, but a bit of foreign talk also. It's a real education, this!
-
Originally posted by hrishy
Well the only realy way to check wheather the database is up or not would be to from a shell script taht can actually login into the databse and do somethin like seelect sysdate from dual;
No need to know any username and or password, no need to actually log into the database to know if it is up and running. Simply try to connect to the database using any existent or non existent database account. If the connection is successfull you know the database is up and running. If you get ORA-1031 "Invalid username or password" you know the database is up and running. In any other case you know the database (or at least one of the needed system components, like listener) is not up and running.
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
-
Thanks for all the valuable responses... I will try it up.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|