Retreive the list of Up/Down status of Oracle database using Shell Script

bashoracle

I am trying to create a shell script for retrieving the list of Oracle database with status UP/DOWN.

Best Answer

Are all the databases running on one server? If so, start with

/home/mark > ps -fu oracle | grep pmon
oracle   15060     1  0  2019 ?        00:28:00 ora_pmon_test01
oracle   53410     1  0 Jan08 ?        00:15:33 ora_pmon_rcatn

And if that output matches what seems reasonable, pipe it through cut:

/home/mark > ps -fu oracle | grep pmon | cut -d_ -f3
test01
rcatn

But that really doesn't verify if the database is fully up and running; you'll likely need something like Jon mentioned in his comments. And anything beyond what I listed above, gets complex quickly.
The PMON process is (to oversymplify) the main watchdog of an Oracle database, so if a PMON process is running, the database might be available and online. 99.9% of the time, yes, but you want to also know if it is accessible.