You are now on my old blog. Please update your bookmarks to my new blog

01 November 2006

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

+ LSC01
+ LSC02
- 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'


Anonymous Anonymous said...

Well of course the number 42 had to appear all over that didn't it?


1/11/06 15:30  
Blogger Laurent Schneider said...

the ultimate alias of life, universe and everything

1/11/06 16:23  
Anonymous Anonymous said...

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.

1/11/06 21:47  
Blogger Laurent Schneider said...

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: does show sqlplus But in the versions I currently use (9208/10202), it does work.

So let me some time to provide you that oneline ;-)

1/11/06 22:30  
Blogger Robert Vollman said...

That's such a simple command, you hardly need an alias for it.

7/11/06 18:31  
Blogger Laurent Schneider said...


7/11/06 21:33  

Post a Comment

<< Home