Statistics Java API

The statistics Java™ API enables a Java-based client application to request statistics.

Calling the Java API

Applications can collect statistics from a Gateway daemon using the Java classes in the com.ibm.ctg.client.stats package. The classes are supplied in a the ctgstats.jar and can be used with Gateway daemons from V7.1 onwards. A sample file Ctgstat1.java is supplied that provides a simple example for using the Java statistics API.

Packaging restrictions with ctgstats.jar

If an application needs to use classes from both the com.ibm.ctg.client.stats package provided by ctgstats.jar and another API package supplied in ctgclient.jar, both jar files must be on the class path and must be from the same product version and release. The implication is that such an application can only connect to a Gateway daemon at the same version or higher for non-statistical requests.

The ctgstats.jar file can be used in isolation for standalone monitoring applications. ctgstats.jar is compatible with ctgclient.jar provided both jar files are from the same version of CICS® TG. Mixing ctgstats.jar and ctgclient.jar that are from different versions of CICS TG is not supported.

Sample code

A sample file Ctgstat1.java is supplied that provides a simple example for using the statistics API.

Java API classes

The Java API classes are responsible for connecting and making statistical requests to a statistics port provided by the Gateway daemon. The constructors allow the destination to be supplied by the application.

The statistic resource groups are available through the getResourceGroupIds method. An IdResultSet object is returned that contains a collection of IdData objects that hold the names of the resource groups. You can iterate over the IdResultSet to search the resource groups available.

If the names of the available statistics are required use the getStatIds method. This method returns an IdResultSet, functioning the same as getResourceGroupIds.

You can retrieve actual statistic values using the getStats method. This method returns a StatResultSet object that contains a collection of StatData objects. These StatData objects contain both the statistic names, and their current values. You can iterate over the StatResultSet to search the statistics available from the request.

If a result set returned has the return code set you can map this to the reason using the getReturnString method of the ResponseData class.

Tracing

You can enable statistics API tracing programmatically using the Java tracing options, see Tracing in Java client programs. Java API errors are reported to the calling application.