org.opennms.netmgt.collectd
Class JMXCollector

java.lang.Object
  extended by org.opennms.netmgt.collectd.JMXCollector
All Implemented Interfaces:
ServiceCollector
Direct Known Subclasses:
JBossCollector, JMXSecureCollector, Jsr160Collector, MX4JCollector

public abstract class JMXCollector
extends Object
implements ServiceCollector

This class performs the collection and storage of data. The derived class manages the connection and configuration. The SNMPCollector class was used as the starting point for this class so anyone familiar with it should be able to easily understand it.

The jmx-datacollection-config.xml defines a list of MBeans and attributes that may be monitored. This class retrieves the list of MBeans for the specified service name (currently jboss and jsr160) and queries the remote server for the attributes. The values are then stored in RRD files.

Two types of MBeans may be specified in the jmx-datacollection-config.xml file. Standard MBeans which consist of and ObjectName and their attributes, and WildCard MBeans which performs a query to retieve MBeans based on a criteria. The current implementation looks like: jboss:a=b,c=d,* Future versions may permit enhanced queries. In either case multiple MBeans may be returned and these MBeans would then be queried to obtain their attributes. There are some important issues then using the wild card appraoch:

  1. Since multiple MBeans will have the same attribute name there needs to be a way to differentiate them. To handle this situation you need to specify which field in the ObjectName should be used. This is defined as the key-field.
  2. The version of RRD that is used is limited to 19 characters. If this limit is exceeded then the data will not be saved. The name is defined as: keyField_attributeName.rrd Since the keyfield is defined in the Object Name and may be too long, you may define an alias for it. The key-alias parameter permit you to define a list of names to be substituted. Only exact matches are handled. An example is: key-alias="this-name-is-long|thisIsNot,name-way-2-long,goodName"
  3. If there are keyfields that you want to exclude (exact matches) you may use a comma separated list like: exclude="name1,name2,name3"
  4. Unlike the Standard MBeans there is no way (currently) to pre-define graphs for them in the snmp-graph.properties file. The only way you can create graphs is to create a custom graph in the Report section. The wild card approach needs to be carefully considered before using it but it can cut down on the amount of work necessary to define what to save.

Author:
Mike Jamison, OpenNMS

Field Summary
 
Fields inherited from interface org.opennms.netmgt.collectd.ServiceCollector
COLLECTION_FAILED, COLLECTION_SUCCEEDED, COLLECTION_UNKNOWN, statusType
 
Constructor Summary
JMXCollector()
           
 
Method Summary
 CollectionSet collect(CollectionAgent agent, EventProxy eproxy, Map<String,Object> map)
          Invokes a collection on the object.
abstract  ConnectionWrapper getMBeanServerConnection(Map<String,Object> map, InetAddress address)
          getMBeanServerConnection
 RrdRepository getRrdRepository(String collectionName)
          getRrdRepository
 String getRRDValue_isthis_used_(JMXDataSource ds, JMXCollectorEntry collectorEntry)
          getRRDValue_isthis_used_
 void initialize(CollectionAgent agent, Map<String,Object> parameters)
          initialize
 void initialize(Map<String,String> parameters)
          initialize
 void release()
          Responsible for freeing up any resources held by the collector.
 void release(CollectionAgent agent)
          release
 String serviceName()
           Returns the name of the service that the plug-in collects ("JMX").
 void setServiceName(String name)
          Setter for the field serviceName.
 void setUseFriendlyName(boolean useFriendlyName)
          Setter for the field useFriendlyName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMXCollector

public JMXCollector()
Method Detail

serviceName

public String serviceName()

Returns the name of the service that the plug-in collects ("JMX").

Returns:
The service that the plug-in collects.

setServiceName

public void setServiceName(String name)

Setter for the field serviceName.

Parameters:
name - a String object.

initialize

public void initialize(Map<String,String> parameters)

initialize

Initialize the service collector.

During initialization the JMX collector: - Initializes various configuration factories. - Verifies access to the database - Verifies access to RRD file repository - Verifies access to JNI RRD shared library - Determines if JMX to be stored for only the node'sprimary interface or for all interfaces.

Specified by:
initialize in interface ServiceCollector
Parameters:
parameters - a Map object.
Throws:
RuntimeException - Thrown if an unrecoverable error occurs that prevents the plug-in from functioning.

release

public void release()
Responsible for freeing up any resources held by the collector.

Specified by:
release in interface ServiceCollector

initialize

public void initialize(CollectionAgent agent,
                       Map<String,Object> parameters)

initialize

Responsible for performing all necessary initialization for the specified interface in preparation for data collection.

Specified by:
initialize in interface ServiceCollector
Parameters:
agent - a CollectionAgent object.
parameters - a Map object.

release

public void release(CollectionAgent agent)

release

Responsible for releasing any resources associated with the specified interface.

Specified by:
release in interface ServiceCollector
Parameters:
agent - a CollectionAgent object.

getMBeanServerConnection

public abstract ConnectionWrapper getMBeanServerConnection(Map<String,Object> map,
                                                           InetAddress address)

getMBeanServerConnection

Parameters:
map - a Map object.
address - a InetAddress object.
Returns:
a ConnectionWrapper object.

collect

public CollectionSet collect(CollectionAgent agent,
                             EventProxy eproxy,
                             Map<String,Object> map)
Invokes a collection on the object. Perform data collection.

Specified by:
collect in interface ServiceCollector
Parameters:
agent - a CollectionAgent object.
eproxy - a EventProxy object.
map - a Map object.
Returns:
a CollectionSet object.

getRRDValue_isthis_used_

public String getRRDValue_isthis_used_(JMXDataSource ds,
                                       JMXCollectorEntry collectorEntry)
                                throws IllegalArgumentException

getRRDValue_isthis_used_

Parameters:
ds -
dsVal -
collectorEntry - a JMXCollectorEntry object.
Returns:
a String object.
Throws:
IllegalArgumentException - if any.

setUseFriendlyName

public void setUseFriendlyName(boolean useFriendlyName)

Setter for the field useFriendlyName.

Parameters:
useFriendlyName - a boolean.

getRrdRepository

public RrdRepository getRrdRepository(String collectionName)

getRrdRepository

Specified by:
getRrdRepository in interface ServiceCollector
Parameters:
collectionName - a String object.
Returns:
a RrdRepository object.


Copyright © 2011. All Rights Reserved.