简体   繁体   中英

Connect between PID and port on ZOS

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM