Collecting resource statistics by using a custom integration application
Start, stop, and review status of resource statistics collection by using custom integration applications.
Before you begin
- Read the concept topic about resource statistics.
About this task
- Checking what resource types can return statistics
/////////////////////////////////////////////////////// // Sample IBM Integration API code that connects to a local integration node // called 'IBNODE' and writes out available // resource types on the integration node that have the // ability to emit resource-level statistics. BrokerProxy b = null; try { b = BrokerProxy.getLocalInstance("IBNODE"); String[] resourceNames = b.getResourceTypeNames(); for (String thisResource : resourceNames) { System.out.println(thisResource); } } catch (ConfigManagerProxyLoggedException e) { e.printStackTrace(); } catch (ConfigManagerProxyPropertyNotInitializedException e) { e.printStackTrace(); }
- Checking for resource names that are associated with a specific resource type
/////////////////////////////////////////////////////// // Sample IBM Integration API code that connects to a local integration node // called 'IBNODE' and writes out resource property // names reported for a specific resource type. BrokerProxy b = null; try { b = BrokerProxy.getLocalInstance("IBNODE"); String[] resourcePropertyNames = b.getResourceTypeStatisticsPropertyNames("JVM"); for (String thisResourceProperty : resourcePropertyNames) { System.out.println(thisResourceProperty); } } catch (ConfigManagerProxyLoggedException e) { e.printStackTrace(); } catch (ConfigManagerProxyPropertyNotInitializedException e) { e.printStackTrace(); }
- Starting statistics collection
/////////////////////////////////////////////////////// // Sample IBM Integration API code that connects to a local integration node // called 'IBNODE' and gets a reference to the execution // group called 'default'. It then enables resource // statistics for all the integration server's resource types. BrokerProxy b = null; try { b = BrokerProxy.getLocalInstance("IBNODE"); ExecutionGroupProxy eg = b.getExecutionGroupByName("default"); if (eg != null) { eg.setResourceStatisticsEnabled(null, true); } } catch (ConfigManagerProxyLoggedException e) { e.printStackTrace(); } catch (ConfigManagerProxyPropertyNotInitializedException e) { e.printStackTrace(); }
- Stopping statistics collection
/////////////////////////////////////////////////////// // Sample IBM Integration API code that connects to a local integration node // called 'IBNODE' and gets a reference to the execution // group called 'default'. It then disables resource // statistics for all the integration server's resource types. BrokerProxy b = null; try { b = BrokerProxy.getLocalInstance("IBNODE"); ExecutionGroupProxy eg = b.getExecutionGroupByName("default"); if (eg != null) { eg.setResourceStatisticsEnabled(null, false); } } catch (ConfigManagerProxyLoggedException e) { e.printStackTrace(); } catch (ConfigManagerProxyPropertyNotInitializedException e) { e.printStackTrace(); }
- Viewing statistics collection status
/////////////////////////////////////////////////////// // Sample IBM Integration API code that connects to a local integration node // called 'IBNODE' and gets a reference to the execution // group called 'default'. It then writes out if resource // statistics is enabled. BrokerProxy b = null; try { b = BrokerProxy.getLocalInstance("IBNODE"); ExecutionGroupProxy eg = b.getExecutionGroupByName("default"); if (eg != null) { System.out.println(eg.getResourceStatisticsEnabled(null)); } } catch (ConfigManagerProxyLoggedException e) { e.printStackTrace(); } catch (ConfigManagerProxyPropertyNotInitializedException e) { e.printStackTrace(); }