IBM Support

Utility to Display the IPv4 Address of Clients Connected to Server Jobs Running on IBM i

Troubleshooting


Problem

This document describes a tool that customers can build to display the IP address of a client connected to a specified job.

Resolving The Problem

This document describes a tool that customers can build to display the IP address of a client connected to a specified job.

When you need to find the IP address of a server job, the normal technique is to display the job log and find the CPIAD02 message. That works great unless the job log wrapped; then, your options are more work intensive. You might use the NETSTAT *CNN list to find all of the connections to the server port the job is using. Use the F15 subset option and place the server port in the local port entry to make the list more concise. You might take a trace and search for any errors that are in the job log (assuming if the job log wrapped, there are a number of errors occurring, and that might not be the case).

There is an easier method. The IPv4 address of the job is stored within the job itself and it can be retrieved by using the QUSRJOBI API. To make this task easier, I wrote a CLP and command that provides the information. To use the tool, you first must download the save file containing the source code for the program and command. Then, upload that to a save file on IBM i, restore the GETIPADDR source file, then compile the program and command.

The save file is available from our public FTP server by using this link: GetIPAddrS.savf

It is assumed that you know how to transfer a save file to the i and restore it. The source file was saved from library MIKSWENS. It is assumed for the case of this example that it was restored to QGPL.  It is also assumed that there is a source physical file QGPL/GETIPADDR that contains the source for the program and member.  It is compiled to the MYSYS library, which is ahead of the QSYS library in your system library list (so that you can override system commands with your own).

To compile the ILE CL program, run the following command:

CRTBNDCL PGM(MYSYS/GETIPADDR) SRCFILE(QGPL/GETIPADDR) SRCMBR(GETIPADDRP) OPTION(*EVENTF) USRPRF(*OWNER) REPLACE(*YES) DBGVIEW(*ALL)

Then, compile the command to call the program:

CRTCMD CMD(MYSYS/GETIPADDR) PGM(*LIBL/GETIPADDR) SRCFILE(QGPL/GETIPADDR) SRCMBR(GETIPADDR) REPLACE(*YES)

You can now use the command. Type GETIPADDR and prompt with the F4 key or provide the job name, job user, and job number as parameters, GETIPADDR QZRCSRVS QUSER 123456

A message is returned that is either the IP address of the client or it states that the job is either connected over the loopback interface or it is not connected at all. If the job is active, as opposed to being in a PSRW state, then it is connected over the loopback interface meaning that the system is connecting to itself.

[{"Product":{"code":"SWG60","label":"IBM i"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Host Servers","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Historical Number

660776463

Document Information

Modified date:
21 October 2021

UID

nas8N1010518