RE: Finding WLS Server Process connecting to Oracle

From: Jorgensen, Finn <Finn.Jorgensen_at_constellation.com>
Date: Thu, 17 Nov 2011 13:55:15 -0500
Message-ID: <9CE162BC5ED2C643956B526A7EDE46FF02A0A560E6A6_at_EXM-OMF-04.Ceg.Corp.Net>



Hi Michael.

I was battling this same problem for years. I finally found a solution in the last month. Here's what to do.

  • get the pid of the process (SPID from v$process)
  • run "pfiles PID". It will give you an output that looks something like what I've pasted below.
  • Look for the section that in my output is labeled 14 (but could be a different label in your output) and make a note of the port for the "peername" (44450 in my example).
  • Log in to the WLS server as the owner of the WL instance. You have to be the owner of the process or root to run the next command.
  • You now have to run "pfiles PID" on every process owned by this user and find the one that says "port: 44450" in the output (that's the port number you got in step 3 above). I wrote a little script to do this job for me. I'm pasting that script below as well. I called it port_pid.ksh. In this way you just run "port_pid.ksh <PORT>".

Thanks,
Finn

oracle> pfiles 2618
2618: oracleCCBPTA (LOCAL=NO)
  Current rlimit: 65536 file descriptors    0: S_IFCHR mode:0666 dev:344,0 ino:6815752 uid:0 gid:3 rdev:13,2

      O_RDONLY|O_LARGEFILE

/devices/pseudo/mm_at_0:null
1: S_IFCHR mode:0666 dev:344,0 ino:6815752 uid:0 gid:3 rdev:13,2 O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE
/devices/pseudo/mm_at_0:null
2: S_IFCHR mode:0666 dev:344,0 ino:6815752 uid:0 gid:3 rdev:13,2 O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE
/devices/pseudo/mm_at_0:null
3: S_IFCHR mode:0666 dev:344,0 ino:6815752 uid:0 gid:3 rdev:13,2 O_RDONLY|O_LARGEFILE
/devices/pseudo/mm_at_0:null
4: S_IFCHR mode:0666 dev:344,0 ino:6815752 uid:0 gid:3 rdev:13,2 O_RDONLY|O_LARGEFILE
/devices/pseudo/mm_at_0:null
5: S_IFREG mode:0644 dev:308,44000 ino:559377 uid:1003 gid:602 size:1092096 O_RDONLY|O_LARGEFILE FD_CLOEXEC
/oracle/product/11.2.0.2/rdbms/mesg/oraus.msb
6: S_IFDOOR mode:0444 dev:353,0 ino:62 uid:0 gid:0 size:0 O_RDONLY|O_LARGEFILE FD_CLOEXEC door to nscd[410]
/var/run/name_service_door
7: S_IFCHR mode:0666 dev:344,0 ino:6815772 uid:0 gid:3 rdev:13,12 O_RDONLY|O_LARGEFILE
/devices/pseudo/mm_at_0:zero
8: S_IFSOCK mode:0666 dev:351,0 ino:10732 uid:0 gid:0 size:0 O_RDWR SOCK_STREAM SO_SNDBUF(49152),SO_RCVBUF(49152),IP_NEXTHOP(0.0.192.0) sockname: AF_INET 0.0.0.0 port: 0 9: S_IFDIR mode:0511 dev:346,0 ino:79364 uid:1003 gid:602 size:832 O_RDONLY|O_LARGEFILE
/proc/02618
14: S_IFSOCK mode:0666 dev:351,0 ino:62327 uid:0 gid:0 size:0 O_RDWR FD_CLOEXEC SOCK_STREAM SO_REUSEADDR,SO_KEEPALIVE,SO_SNDBUF(49152),SO_RCVBUF(49640),IP_NEXTHOP(0.0.193.232) sockname: AF_INET 10.103.121.119 port: 1571 peername: AF_INET 10.103.122.18 port: 44450 256: S_IFREG mode:0640 dev:308,25000 ino:27 uid:1003 gid:602 size:22020104192 O_RDWR|O_DSYNC|O_LARGEFILE|0x20 FD_CLOEXEC advisory write lock set by process 1118
/CCBPTA01/system01.dbf
257: S_IFREG mode:0640 dev:308,25000 ino:17 uid:1003 gid:602 size:75505664 O_RDWR|O_DSYNC|O_LARGEFILE|0x20 FD_CLOEXEC advisory write lock set by process 1118 258: S_IFREG mode:0640 dev:308,25000 ino:32 uid:1003 gid:602 size:19120128 O_RDWR|O_DSYNC|O_LARGEFILE|0x20 FD_CLOEXEC advisory write lock set by process 1894
/CCBPTA01/control01.ctl
259: S_IFREG mode:0640 dev:308,25000 ino:33 uid:1003 gid:602 size:19120128 O_RDWR|O_DSYNC|O_LARGEFILE|0x20 FD_CLOEXEC advisory write lock set by process 1894
/CCBPTA01/control02.ctl
260: S_IFREG mode:0640 dev:308,25000 ino:34 uid:1003 gid:602 size:19120128 O_RDWR|O_DSYNC|O_LARGEFILE|0x20 FD_CLOEXEC advisory write lock set by process 1894 ================================

port_pid.ksh :

#!/bin/ksh
# find from a port the pid that started the port
#
line='-------------------------------------------------------------------------'
username=`whoami`
pids=`/usr/bin/ps -fu $username | sed 1d | awk '{print $2}'`

# Prompt for port or use 1st cmdline argument if [ $# -eq 0 ]
then
  read ans?"Enter port you like to know pid for: " else
  ans=$1
fi

#Check all pids for this port, then list that process for f in $pids
do

        /usr/proc/bin/pfiles $f 2>/dev/null | /usr/xpg4/bin/grep -q "port: $ans"
        if [ $? -eq 0 ] ; then
        echo "$line\nPort: $ans is being used by PID: \c"
        /usr/bin/ps -o pid -o args -p $f | sed 1d
        fi

done
exit 0

-----Original Message-----
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Michael Dinh Sent: Wednesday, November 16, 2011 5:27 PM To: Michael Dinh; 'oracle-l_at_freelists.org' Subject: RE: Finding WLS Server Process connecting to Oracle

My apologies.
WLS is Weblogic server.

> uname -an
SunOS 5.10 Generic_142909-17 sun4u sparc SUNW,SPARC-Enterprise

Solaris 10 Sparc 64bit.

Michael Dinh

Hello,

We have WLS using connection pooling for Oracle 11.2.0.3 database.

There are sessions that have gone rogue and is it possible to find the server process from the WLS that is connection to Oracle server from a connection pool.

I can determine the server process from Oracle server, but what I need to find is the server process from WLS itself.

Is this possible?

MDINH_at_db03> select sid, serial#, process, program from v$session where status='ACTIVE' and program like 'JDBC%'   2 ;

       SID    SERIAL# PROCESS                  PROGRAM
---------- ---------- ------------------------ ------------------------------------------------
       382      31637 1234                     JDBC Thin Client
       693      24029 1234                     JDBC Thin Client
      1060      64669 1234                     JDBC Thin Client

MDINH_at_db03>

Thanks

Michael Dinh
>>> This e-mail and any attachments are confidential, may contain legal, professional or other privileged information, and are intended solely for the addressee. If you are not the intended recipient, do not use the information in this e-mail in any way, delete this e-mail and notify the sender. CEG-IP2

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Nov 17 2011 - 12:55:15 CST

Original text of this message