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 \042select \047+ "$1" \011\047||version from v\\$instance;\042|ORACLE_SID="$1" ORACLE_HOME="$2" "$2"/bin/sqlplus -s \042/ as sysdba\042 2>/dev/null|grep \042^+\042||echo \042- "$1"\042")}' /etc/oratab
Or, as an alias :
alias oraver='awk -F: '\''/^[^*# ]/{system("echo \042select \047+ "$1" \011\047||version from v\\$instance;\042|ORACLE_SID="$1" ORACLE_HOME="$2" "$2"/bin/sqlplus -s \042/ as sysdba\042 2>/dev/null|grep \042^+\042||echo \042- "$1"\042")}'\'' /etc/oratab'
Here it is :
awk -F: '/^[^*# ]/{system("echo \042select \047+ "$1" \011\047||version from v\\$instance;\042|ORACLE_SID="$1" ORACLE_HOME="$2" "$2"/bin/sqlplus -s \042/ as sysdba\042 2>/dev/null|grep \042^+\042||echo \042- "$1"\042")}' /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 \042select \047+ "$1" \011\047||version from v\\$instance;\042|ORACLE_SID="$1" ORACLE_HOME="$2" "$2"/bin/sqlplus -s \042/ as sysdba\042 2>/dev/null|grep \042^+\042||echo \042- "$1"\042")}'\'' /etc/oratab'
6 Comments:
Well of course the number 42 had to appear all over that didn't it?
;-)
the ultimate alias of life, universe and everything
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.
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 ;-)
That's such a simple command, you hardly need an alias for it.
LOL
Post a Comment
<< Home