Created
February 21, 2019 15:37
-
-
Save theothermattm/15bed523cf60710f1d342fa2d8352105 to your computer and use it in GitHub Desktop.
Bash script to check health of an oracle instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# original source based on: https://github.com/fabiohbarbosa/docker-healthcheck-oracle/blob/master/assets/healthcheck.sh | |
CHECK=$(${ORACLE_HOME}/bin/sqlplus -s ${HEALTHCHECK_USER}/${HEALTHCHECK_PASSWORD}@localhost/${HEALTHCHECK_SERVICE_NAME} as sysdba <<END | |
--set pagesize 0 feedback off verify off heading off echo off; | |
-- the simplest type of health check | |
--select count(*) from dual; | |
-- this will check if a | |
SELECT count(*) FROM V\$INSTANCE where INSTANCE_NAME = 'xe' and DATABASE_STATUS = 'ACTIVE'; | |
exit; | |
END | |
) | |
## Number check | |
#if ! [ "${CHECK}" -eq "${CHECK}" ] 2>/dev/null; then | |
# echo ${CHECK} | |
# exit 1 | |
#fi | |
# | |
## Exist table check | |
#if [ ${CHECK} -gt 0 ]; then | |
# echo "Healthy" | |
# exit 0 | |
#else | |
# exit 1 | |
#fi | |
if [[ ${CHECK} == *"x"* ]]; then | |
echo "Healthy" | |
exit 0 | |
else | |
echo "Unhealthy: ${CHECK}" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment