Show TOC Start of Content Area

Function documentation Installation of Monitors  Locate the document in its SAP Library structure

Use

To install monitors, it is necessary to initialize more input parameters than when you install summary/object nodes.

The following example can be used to see how the integer monitor described in the monitor-configuration.xml section can be installed:

·        Monitor installation using XML:

<integer-monitor name="ExportedRemoteObjectsCount" configuration group="P4.ExportedRemoteObjectsCount">

   <monitored-resource name="p4" type="SERVICE"/>

   <integer-attribute-mapping>

      <integer-attribute>

          <observed-resource-attribute name="ExportedRemoteObjectsCount"/>

      </integer-attribute>

   </integer-attribute-mapping>

</integer-monitor>

 

·        Monitor installation using the following code snippet:

byte monitorType = MonitorConstants.INTEGER_MONITOR;

 

   String path = "Root/Services/P4 Provider";

   String name = "ExportedRemoteObjectsCount";

   String cfgGroup = " P4.ExportedRemoteObjectsCount ";

       

   String monitoredResourceName = "p4";

   String monitoredResourceType = MonitorConstants.RESOURCE_SERVICE;

 

   CallInfo info = new CallInfo(CallInfo.INTEGER_MONITOR_VALUE, "ExportedRemoteObjectsCount");

   Vector callInfos = new Vector();

   callInfos.add(info);

 

   monitorContext.installMonitor(monitorType, path, name, cfgGroup, monitoredResourceName, monitoredResourceType, callInfos);

 

Features

To install any kind of monitor (except table and state monitors), the required input parameters are:

·        The monitor type (all available monitor types can be obtained from com.sap.engine.interfaces.monitor.MonitorConstants).

·        The path in the monitor tree where the monitor has to be placed (must be valid, that is, not null and existing).

·        The name of the monitor (must be valid, that is, not null and unique).

·        The configuration group (must be valid, that is, already deployed on server).

·        The monitored resource name.

·        The monitored resource type (all available resource types can be obtained from com.sap.engine.interfaces.monitor.MonitorConstants).

·        Attribute mapping information (the name of the method that provides the monitor value).

The purpose of all parameters is more or less obvious. The only parameter that may be a little more complicated is the vector with CallInfo objects. A CallInfo object is intended to hold information about the MBean attribute the monitor is interested in.

There are two constructors:

·        public CallInfo(String mappingAttributeName, String attributeName)

·        public CallInfo(String mappingAttributeName, String operationName, Object[] parameters, String[] signatures)

The first one has to be used when the called operation does not require input parameters; the second is used when the caller provides input parameters for the called method.

Example

Let there be an MBean with three methods. How a corresponding vector with CallInfo object(s) for each of them can be created?

Example 1 – use an MBean method without parameters:

// mbean method for creation of a frequency monitor

public int getTransactionFrequency();

 

// the corresponding vector with the CallInfo object

String attributeName = "TransactionFrequency";

CallInfo info = new CallInfo(CallInfo.FREQUENCY_REPORTED_EVENTS, attributeName);

Vector callInfos = new Vector();

callInfos.add(info);

 

Example 2 – use an MBean method without parameters:

// MBean methods for creation of a quality rate monitor

public long getTotalClientTransactions();    // all transactions

public long getExceededTransactions();       // transactions exceeding 10 000 euro

 

// the corresponding vector with the CallInfo objects

Vector callInfos = new Vector();

 

String attributeNameTotal = "TotalClientTransactions";

CallInfo infoTotal = new CallInfo(CallInfo.QUALITY_RATE_TOTAL_TRIES_FROM_STARTUP, attributeNameTotal);

callInfos.add(infoTotal);

 

String attributeNameExceeded = "ExceededTransactions";

CallInfo infoExceeded = new CallInfo(CallInfo.QUALITY_RATE_TOTAL_SUCCESSFUL_TRIES_FROM_STARTUP, attributeNameExceeded);

callInfos.add(infoExceeded);

 

Example 3 – use an MBean method with parameters:

// MBean method for creation of a long monitor

public long getTransactionDuration(String clientName);

 

// the corresponding vector with the CallInfo object

Object[] parameters = new Object[]{"Transaction No:1"};

String[] signatures = new Object[]{"java.lang.String"};

String operationName = "getTransactionDuration";

 

CallInfo info = new CallInfo(CallInfo.LONG_MONITOR_VALUE, operationName, parameters, signatures);

Vector callInfos = new Vector();

callInfos.add(info);

 

The parameters array contains parameters passed to the MBean method. The signatures array contains parameter’s types.

The length of the signatures array must be equal to the length of the parameter’s array, since there has to be a corresponding type in the signatures array for each parameter.

 

See also:

Installation of Table and State Monitors

Uninstallation of Summary Nodes, Object Nodes, and Monitors

 

End of Content Area