Wednesday, September 9, 2009

How to Check the Environment Variables for an Oracle Process

1. Determine the pid of the process at OS level, eg for the smon process:
ps -ef grep smon
2. Get the environment of the process:
SOLARIS:
pargs -e grep ORACLE
LINUX:
cat /proc//environ
AIX:
ps eauwww
HP-UX:
On this Unix flavor there is no command to grasp the process environment directly. This can only be
extracted using a debugger from the _environ structure. This procedure can be used on the other
Unix flavors, as follows:
gdb smon
This attaches gdb to the pid mentioned above. The smon name is just an indication that the process
we attach to is smon, but the only parameter that matters is the pid.
After attaching to the process, the following command extracts the information from the _environ
list:
p ((char**)_environ)[0]@30
which would list the first 30 environment variables. If more are defined, just increase the parameter after @.
As well, the list can be extracted one item from the list at a time, using an iterator like:p ((char**)_environ)[i]
which would extract element #i+1.Windows:
To get the information on Windows, 2 things are needed:
1. check the registry for the ORACLE_* keys used to start the Oracle process. These keys are in:
HKEY_LOCAL_MACHINE/Software/Oracle/HOME
(before 10g)
HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/KEY_
from 10g on.
2. check the environment variables that were used by the oracle process at startup.
For this, one would need the process explorer utility from sysinternals, which can be found at:
www.sysinternals.com
(http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx)
After starting the procexp utility, find the oracle process you want to check in the process list, right
click on it, then select Properties. The Environment tab should indicate all the environment variables
used when the process was started (even if dynamically in command line).
The utility also displays the key values from registry, but being so many it's difficult to look for them.

1 comment:

Unknown said...

once upon a time I have heard about other software tools to recover database in sql server 2005. hope it helps