Using the Health Center API

See: Description

Using the Health Center API

You can use the Health Center API to write your own code for manipulating Health Center data.

Before you begin

The API is provided in two versions:
A plug-in version, which you can use in Eclipse. You must have an instance of Eclipse Version 3.4, or later.
An ordinary .jar file, which you can use with an existing Java application. You must have IBM SDK, Java Technology Edition, Version 6 or later.

About this task

Typically, you use the Health Center client GUI to view and analyze the data from a monitored application. However, you might want to see only a small subset of the data, or you might want to manipulate the data in a way that you cannot currently do with the GUI. By using the Health Center API, you can write a Java application that manipulates the Health Center data according to your requirements.

When you use the Health Center API in an application, an instance of the Health Center client is embedded in your application; your application then uses this instance to connect to the Health Center agent.

Procedure


Optional: To use the plug-in version of the API, install Health Center into Eclipse: Follow the instructions in the Eclipse documentation for installing new software, using the following URL for the software site:
http://public.dhe.ibm.com/software/websphere/runtimes/tools/healthcenter/
Step 1 - Create a Java application in Eclipse. Use the Eclipse documentation if you need further information for this step.

Optional: To use the API with an existing Java application, complete the following steps: Obtain the monitoringapi.jar package from Health Center.
Specify the monitoringapi.jar file in the command that you use to run the application.

Step 2 -Add Health Center code to your applicationCreate a ConnectionProperties object, optionally specifying the host name and port number.
This object stores the information that is required to connect the Health Center client within your application to the Health Center agent.
Pass the ConnectionProperties object into the HealthCenterFactory.connect(ConnectionProperties props, boolean autoScan) method, to return a HealthCenter object. This object represents the connection to the monitored application.
Use the HealthCenter object to retrieve data from the application. You can also use the HealthCenter object to limit the amount of data that is returned from a running application. For more information about the data that you can retrieve, and the associated methods and classes, see the API documentation.
For example:
...

// Create the connection object:
ConnectionProperties conn1 = new ConnectionProperties("localhost", 1973);

// Connect to the Health Center agent, using the previous connection settings:
HealthCenter hcObject = HealthCenterFactory.connect(conn1, true);

// Get garbage collection data and print:
GCData gcData = hcObject.getGCData();
System.out.println("GC Mode is " + gcData.getGCMode().toString());

...
You can also connect to a saved file, instead of a running application, by using the HealthCenterFactory.connect(java.io.File filename) method.
The HealthCenter class HealthCenter can be used to give access to the data stored by Health Center. You can set time thresholds, preferences and get access to each type of data from this class.
� Copyright 2012, 2016 IBM Corporation.