Express (Distributed operating systems), v8.0 > Troubleshoot and support > Analyzing application server Java system dumps with the IBM Monitoring and Diagnostic Tools for Java - Dump Analyzer > Write a new analysis module or script > Write and running a new analysis module


Write an analyzer that implements IAnalyze

When creating your analysis module that implements the IAnalyze interface use the New Class Wizard (right click on the package you created in the Prepare to write an analyzer section and select New > Class). In the resultant wizard enter the following:

Clicking Finish will create a DWAnalyze analyzer class with the necessary stub methods.

To follow along with the example enter the code detailed in List 1. This simple example determines whether the dump was created on a multi processor machine.

List 1. Example of an Analyzer that implements IAnalyze

 package mypackage;

import com.ibm.dtfj.analyzer.base.AnalyzerBase;
import com.ibm.dtfj.analyzer.ext.IAnalyze;
import com.ibm.dtfj.image.DTFJException;
import com.ibm.dtfj.image.Image;
import com.ibm.util.SimpleVector;

/**
 * This is the basic design required to implement an IAnalyze Interface
 */
public class DWAnalyze extends AnalyzerBase implements IAnalyze {

    private static String description = "Check the number of processors";

    /*
     * This rule checks if the processor count is greater than 1
     */
    private static String[] multiProcessorRules = {

       "processorCount > 1     TRUE"
    };

    /**
     * An analyzer to report if the dump was produced on a multiprocessor machine
     */
    public DWAnalyze() {
        defineRule("isMultiProcessor",multiProcessorRules);
    }

   /* (non-Javadoc)
    * @see com.ibm.dtfj.analyzer.base.AnalyzerBase#getShortDescription()
    */
    public String getShortDescription() {
        return description;
    }

   /* (non-Javadoc)
    * @see com.ibm.dtfj.analyzer.ext.IAnalyze#doAnalysis()
    */
    public String[] doAnalysis() {
        return checkProcessors(getContext().getCurrentImage());
    }

    /**
     * This function uses the getProcessorCount() function from the Image class
     * and then adds an entry into the ret[] array for parsing through the analysisRules[]
     * array.  The format for passing through the analysisRules needs to be of the type
      *name=value
     */
    private String[] checkProcessors(Image image) {
     ret = null;
        try {
            int procNum = image.getProcessorCount();
            ret = new String[1];
            ret[0] = "processorCount=" + procNum;
        } catch (DTFJException e) {
            handleError("No processor information",e);
        }
        return ret;
    }
}



We can see from this example that there are two methods that require an implementation: getShortDescription() and doAnalysis(). The aim of the doAnalysis method is to extract information from the dump and return it in the form of name=value pairs. That information is then further analyzed in the above example by making use of some default behaviour of AnalyzerBase which is able to process some simple analysis rules. Each rule operates on the set of name=value pairs and selects a specific name to test against a value. In the above example the result of the rule processing is true if there is an item with name 'processorCount' and value greater than 1.

To see this analysis module in action - skip on to the Run an analyzer section.

disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

+

Search Tips   |   Advanced Search