How to find the client of a UDS connection?
NOTE: for Linux servers only!
SAP uses UDS (UNIX Domain Sockets) communication if both the client and server processes are on the same server, through the "sapstream" files ("/tmp/.sapstreamXXXX").
It might be required to identify the client(s) of an UDS connection.
While logged on as "root", we start by using netstat to identify the "server port" of the UDS connection:
server:~ # netstat -an|grep sapstream3201 unix 2 [ ACC ] STREAM LISTENING 61392 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 720784 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 718288 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 716834 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 716871 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 712696 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 720785 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 716968 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 716824 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 66915 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 2279796 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 718132 /tmp/.sapstream3201 unix 3 [ ] STREAM CONNECTED 718009 /tmp/.sapstream3201 server:~ #
The "server port" is the number to the left of the "sapstream" file.
Then, we use the "ss" command to identify the peers related to that "port". For example, using the "port" number 2279796 (columns' spacing were adjusted for clarity purposes):
server:~ # ss -a --unix -p|egrep "(Netid|2279796)" Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port u_str ESTAB 0 0 * 2279795 * 2279796 users:(("SID_00_BTC_W10",pid=18843,fd=18)) u_str ESTAB 0 0 /tmp/.sapstream3201 2279796 * 2279795 users:(("en.sapSID_ASCS0",pid=29745,fd=36)) server:~ #
Notice that the "ports" can be matched:
- "port" 2279795 is seen at the local address of the BTC work process 10, and at the peer address of the Enqueue process, which is the server of the connection (and creator of the UDS / sapstream3201).
- "port" 2279796 is seen at the peer address of the BTC work process 10, and at the local address of the Enqueue.
- Important: both have "State" as "ESTAB" (established).
Conclusion:
The client of the UDS connection:
unix 3 [ ] STREAM CONNECTED 2279796 /tmp/.sapstream3201
is the work process 10.