alias oraver 2.0

Thanks to an anonymous comment in my post yesterday, I can now provide a more flexible version of my alias, which do not require the database to be running nor the sysdba privilege

$ alias oraver
oraver=’echo ‘\”ORACLE_SID VERSION %CPU RSZ VSZ START_TIME’\”;awk -F: ‘\”/^[^ *#]/{print “printf 42%-9s %11s %5s %8s %8s %s\\n42″,$1,”$(ORACLE_HOME=”$2,$2″/bin/sqlplus -v 2>/dev/null|cut -d47 47 -f3) $(ps -eo pcpu,rsz,vsz,start_time,args|sed -n 42s/ [o]ra_pmon_”$1″.*//p42)”}’\” /etc/oratab |sh’
$ oraver

LSC01   0.0    12184   508448 10:09
LSC02   0.0     8420   303320 10:10

Well, it is based on the sqlplus version, which is not necessarly the same as database version, like does show, but in most of the recent versions, it should be ok

ps parameters may not work on all os, you can use -ef if you prefer

4 Replies to “alias oraver 2.0”

  1. I’ll leave you another anonymous tip and have you check out $ORACLE_HOME/bin/sysresv
    I’m not sure how reliable it is across platforms and versions though. And it may only work under the oracle OS user account.

  2. tweaked it a bit so it displays ASM instances. I also changed it to show the proper process info for 2 similar SIDs (i.e RACDB and RACDB1). it used to list the process info twice, even though only one instance was running. I only tested it on linux.

    alias oraver=’echo ”’ORACLE_SID VERSION %CPU RSZ VSZ START_TIME”’;awk -F: ”’/^[^ *#]/{print “printf 42%-9s %11s %5s %8s %8s %s\n42″,$1,”$(ORACLE_HOME=”$2,$2″/bin/sqlplus -v 2>/dev/null|cut -d47 47 -f3)”,”$(ps -eo pcpu,rsz,vsz,start_time,args|sed -n 42s/ [o]ra_pmon_”$1″$//p;s/ [a]sm_pmon_”$1″$//p42)”}”’ /etc/oratab |sh’

  3. I could not test this, but I added a test for the agents, in case the agent is listed in /etc/oratab like


    alias oraver=’echo ”’ORACLE_SID VERSION %CPU VSZ START_TIME”’;
    echo ”’———- ———- —– ——– ———-”’;
    awk -F: ”’/^[^ *#]/&&!/^agent/{print “printf 42%-9s %11s %5s %8s %s %s %s %s\n42″,$1,”$(ORACLE_HOME=”$2,$2″/bin/sqlplus -v 2>/dev/null|cut -d47 47 -f3) $(ps -eo pcpu,vsz,start_time,args|sed -n 42s/ [o]ra_pmon_”$1″.*//p42)”}
    /^agent/{print “printf 42%-9s %11s %5s %8s %s %s %s %s\n42”,$1,”$(“$2″/bin/emctl getversion|awk 47{r=$NF}END{print r}47) $(ps -eo pcpu,vsz,start_time,args|sed -n 42s, /.*[e] agent .*/”$1″/.*,,p42)”}
    ”’ /etc/oratab |sh’

Leave a Reply