Skip to content

Instantly share code, notes, and snippets.

@dotmaik1
Created October 6, 2016 16:29
Show Gist options
  • Select an option

  • Save dotmaik1/ccdb92504f035de3ad6b492b63523e16 to your computer and use it in GitHub Desktop.

Select an option

Save dotmaik1/ccdb92504f035de3ad6b492b63523e16 to your computer and use it in GitHub Desktop.
Automatic script that checks if the database is open an accesible
#!/bin/bash
ORACLE_SID=MXBRIDGE
export ORACLE_SID
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/MXBRIDGE
export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin
export PATH
mailto="[email protected]"
TIMING=`date +"%d-%b-%Y %H:%M"`
$ORACLE_HOME/bin/sqlplus scott/tiger@'(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lfoitmatdb01.foit-foxconn.net)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = MXBRIDGE) (FAILOVER_MODE = (TYPE = select) (METHOD = basic))))' <<END
--select sysdate from dual;
exit;
END
tmp=$?
#echo $tmp
if [ $tmp -gt 0 ]
then
echo "MXBRIDGE not able to connect..Please check Database / listener & address Immediately" | mailx -s "Critical | lfoitmatdb01 - MXBRIDGE DB Not able to Connect | $TIMING " $mailto
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment