ps -ef |grep pmon alternative

I just wrote a new alias to check if the databases are up and running. I added the version and a dash for non-running database. Needed is /etc/oratab + sysdba access to the database.

Here it is :

awk -F: ‘/^[^*# ]/{system(“echo 42select 47+ “$1″ 1147||version from v\\$instance;42|ORACLE_SID=”$1″ ORACLE_HOME=”$2” “$2″/bin/sqlplus -s 42/ as sysdba42 2>/dev/null|grep 42^+42||echo 42- “$1″42”)}’ /etc/oratab

+ LSC01         10.2.0.2.0
+ LSC02         9.2.0.8.0
- LSC03

Or, as an alias :

alias oraver=’awk -F: ‘\”/^[^*# ]/{system(“echo 42select 47+ “$1″ 1147||version from v\\$instance;42|ORACLE_SID=”$1″ ORACLE_HOME=”$2” “$2″/bin/sqlplus -s 42/ as sysdba42 2>/dev/null|grep 42^+42||echo 42- “$1″42″)}’\” /etc/oratab’

6 thoughts on “ps -ef |grep pmon alternative

  1. Anonymous

    Assuming sqlplus (or exp / imp and other utilites for that matter) also are relinked when patch sets are applied, then you may be able to use the version in the tool’s banner as the version of Oracle even if the instance is down.

  2. Laurent Schneider

    yes and no!
    on the one hand, you can do sqlplus -version, which is a very good hint to me, I may want to update my alias to do that (because it works even when down and even when not sysdba)
    on the other hand, you cannot see the instance level in sqlplus, because some patch does not affect sqlplus. Ex: 8.1.7.3 does show sqlplus 8.1.7.0. But in the versions I currently use (9208/10202), it does work.

    So let me some time to provide you that oneline 😉

Comments are closed.