July 10, 2012

Work With Traces

In the 5.4 release, IBM introduced the Work with Traces (WRKTRC) command. This is a handy little utility that allows you to review all the traces that may be active on a partition, as well as a centralized interface for managing traces.

Why is the WRKTRC a convenient tool? IBM i has very strong diagnostic capabilities and one of the reasons is due to the wide variety of diagnostic data that you can collect. However, different types of diagnostic data are often collected in different ways. In fact, there are several different trace facilities available on i:

Job TraceJob trace (STRTRC) traces the program flow (among other things) within a job. I blogged about job trace some time ago in the article IBM i Job Trace. The Trace Job (TRCJOB) command still exists, but it now invokes STRTRC automatically. A little secret about Job Trace is that it uses Performance Explorer trace under the covers for the data collection; however, job trace does much more than just provide a customized interface over Performance Explorer.

Performance Job TraceStart Job Trace (STRJOBTRC) is a job trace function to collect performance statistics. As of the 6.1 release, it invokes STRTRC.

Licensed Internal Code (LIC) traces LIC traces can be started by going into System Service Tools (SST) or Dedicated Service Tools (DST) and starting the LIC trace service function. The Trace Internal (TRCINT) command is a command interface to LIC trace that alleviates the need to go into SST or DST to start or manage your LIC traces.

Trace Connection The Trace Connection (TRCCNN) command, which provides a trace similar to a communications trace, actually does a LIC trace under the covers, so TRCCNN will start a TCP/IP or Sockets LIC trace.

Trace TCP ApplicationTrace TCP Application (TRCTCPAPP) is a specialized interface for starting traces specifically for a set of TCP/IP Application Servers. Of interest is that you can also start additional traces when you trace a TCP/IP application server, such as job traces or LIC traces.

As you can see, there are a wide variety of interfaces to collect trace data, but it really comes down to four basic types of trace data collection:

Job Trace

Performance Explorer

LIC Trace

Communications Trace

The Work with Traces command can allow you to manage any one (or all) of these traces. It has one parameter – the Trace (TRC) parameter – which allows you to specify which traces you want to work with. Supported values are:

*ALL – work with all traces

*CMN – work with communications traces

*JOB – work with job traces

*LIC – work with LIC traces

*PEX – work with Performance Explorer traces

When you first go into the WRKTRC interface, you will see the traces that are applicable based upon the TRC parameter. If there are no traces active, a message will be displayed stating that no traces are found. What's particularly useful with WRKTRC *ALL is it will show you all the traces that exist on the system in some form (active or ended); it is not uncommon to start a trace but forget that it is running; WRKTRC can help you determine if you have forgotten traces that are still running. Or perhaps you have a trace you started and ended, but never deleted (to free up storage); WRKTRC will show you those traces.

The F6 key allows you to start a new trace. You can then select the type of trace you want from the menu options listed. The appropriate command prompt interface for starting your selected trace is then displayed.

In the following screen capture, you will see an example of working with traces with one trace of each type active:

The following screen capture is an example of working with traces when there is a trace of each type that has been ended:

For any trace, you can take actions that are appropriate for that trace type and the state that it is in. Details of what actions are appropriate for what trace types can be found in the online help. The online help also describes the various statuses that can occur for each type of trace.

Finally, there are some additional diagnostic trace capabilities that exist on i that are not supported with WRKTRC; this is because these trace types are not commonly used any more. For example, Trace CPI Communications (TRCCPIC) and Trace ICF (TRCICF) are related to SNA communications functions. User Trace (xxxUSRTRC) is replaced with Job Trace.

IBM Systems Magazine is a trademark of International Business Machines Corporation. The editorial content of IBM Systems Magazine is placed on this website by MSP TechMedia under license from International Business Machines Corporation.