2

My question relates to ZOS 2.1 and 1.13, I am looking for a command in ZOS like

netstat -ano

in Windows.

I have a port number of TCP Connection and I want to know the PID that connects to it.

I know a system MVS command for users and TCP:

/d omvs,asid=all

but the output does not include the PID.

Are there any shell command from USS (OMVS) MVS, Rexx, or a Java function?

Clashsoft
  • 11,553
  • 5
  • 40
  • 79
Nessi
  • 51
  • 1
  • I'm pretty sure there doesn't have to be a pid, i.e. if a STC like CICS has a port open there may not be a PID. I presume you've reviewed the z/Unix netstat command documentation at https://www-01.ibm.com/support/knowledgecenter/#!/SSLTBW_1.13.0/com.ibm.zos.r13.halu101/concepts.htm%23wq392 and it doesn't do what you want. – cschneid Nov 15 '15 at 15:54

1 Answers1

1

The console command you want would be "D TCPIP,CONN". This will show you the state of all the various network connections, and you can line up the output with the "D OMVS,A=ALL" command you mentioned to determine the PID for any open socket connection.

Note that if your site runs multiple TCP/IP stacks, you'll need to know the jobname of the TCPIP stack owning the connection you're interested in. The "D TCPIP,DEVLINK" command can help you with this...typically, if you run multiple stacks, each would be servicing different IP addresses (and devices). You'd need to know what you connect to (IP address and port), then associate the IP address with a TCP/IP stack jobname, then you can get the data you want.

If you need to do this sort of thing from the USS shell, you can also use the "ps" and "netstat" commands to get this same data. There are also APIs that would let you do this stuff programmatically from C/C++ or possibly Java if you don't mind a bit of intervening JNI code.

Note that the comment you received about "there may not be a PID" is generally not true. When an application opens a socket, it's first "dubbed" as a UNIX Services process, and this means that the caller gets assigned a process ID. Indeed, sometimes you have the opposite problem - a sophisticated app with many subtasks can sometimes end up with multiple PIDs in a single address space.

Valerie R
  • 1,769
  • 9
  • 29
  • Since the OP tagged Rexx, netstat can be invoked directly using the USS environment. I am on the road and cannot point to specifics, but there is a manual for accessing USS things from Rexx under TSO or IRXJCL. – zarchasmpgmr Nov 30 '15 at 21:52