Class JMXCollector
- java.lang.Object
-
- org.opennms.netmgt.collection.api.AbstractServiceCollector
-
- org.opennms.netmgt.collection.api.AbstractRemoteServiceCollector
-
- org.opennms.netmgt.collectd.JMXCollector
-
- All Implemented Interfaces:
ServiceCollector
- Direct Known Subclasses:
Jsr160Collector
public class JMXCollector extends AbstractRemoteServiceCollector
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 retrieve 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 approach:
- 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.
- 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"
- If there are keyfields that you want to exclude (exact matches) you
may use a comma separated list like:
exclude="name1,name2,name3"
- 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
-
-
Constructor Summary
Constructors Constructor Description JMXCollector()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.util.Map<java.lang.String,JMXDataSource>
buildDataSourceList(java.lang.String collectionName, java.util.Map<java.lang.String,java.util.List<Attrib>> attributeMap)
This method is responsible for building a list of RRDDataSource objects from the provided list of MBeanObject objects.CollectionSet
collect(CollectionAgent agent, java.util.Map<java.lang.String,java.lang.Object> map)
Invokes a collection on the object.protected JmxConnectors
getConnectionName()
RrdRepository
getRrdRepository(java.lang.String collectionName)
Retrieve theRrdRepository
configuration for the given collection.java.util.Map<java.lang.String,java.lang.Object>
getRuntimeAttributes(CollectionAgent agent, java.util.Map<java.lang.String,java.lang.Object> parameters)
Invoked before every call to#collect(CollectionAgent, EventProxy, Map)
in order to retrieve state/runtime information required for perform the collection.void
initialize()
Initialize the collector.java.lang.String
serviceName()
Returns the name of the service that the plug-in collects ("JMX").void
setJmxConfigDao(JmxConfigDao jmxConfigDao)
void
setJmxDataCollectionConfigDao(JMXDataCollectionConfigDao jmxDataCollectionConfigDao)
void
setServiceName(java.lang.String name)
Setter for the fieldserviceName
.-
Methods inherited from class org.opennms.netmgt.collection.api.AbstractRemoteServiceCollector
getEffectiveLocation, marshalParameters, unmarshalParameters
-
Methods inherited from class org.opennms.netmgt.collection.api.AbstractServiceCollector
validateAgent
-
-
-
-
Method Detail
-
serviceName
public java.lang.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(java.lang.String name)
Setter for the field
serviceName
.- Parameters:
name
- aString
object.
-
initialize
public void initialize()
Description copied from interface:ServiceCollector
Initialize the collector. This call will be invoked in OpenNMS before any other calls to the collector are made. This function may be invoked several times during the lifetime or the collector.- Specified by:
initialize
in interfaceServiceCollector
- Overrides:
initialize
in classAbstractServiceCollector
-
getRuntimeAttributes
public java.util.Map<java.lang.String,java.lang.Object> getRuntimeAttributes(CollectionAgent agent, java.util.Map<java.lang.String,java.lang.Object> parameters)
Description copied from interface:ServiceCollector
Invoked before every call to#collect(CollectionAgent, EventProxy, Map)
in order to retrieve state/runtime information required for perform the collection. This call will always be performed in OpenNMS.- Specified by:
getRuntimeAttributes
in interfaceServiceCollector
- Overrides:
getRuntimeAttributes
in classAbstractServiceCollector
- Parameters:
agent
- Includes details about to the agent from which we wish to collect.parameters
- Includes the service parameters defined in collectd-configuration.xml.- Returns:
- Additional attributes, which should be added to the parameter map before calling
#collect(CollectionAgent, EventProxy, Map)
.
-
getConnectionName
protected JmxConnectors getConnectionName()
-
collect
public CollectionSet collect(CollectionAgent agent, java.util.Map<java.lang.String,java.lang.Object> map)
Description copied from interface:ServiceCollector
Invokes a collection on the object. This call will be performed in both OpenNMS and Minion.- Parameters:
agent
- aorg.opennms.netmgt.collectd.CollectionAgent
object.map
- aMap
object.- Returns:
- a
org.opennms.netmgt.config.collector.CollectionSet
object.
-
buildDataSourceList
protected static java.util.Map<java.lang.String,JMXDataSource> buildDataSourceList(java.lang.String collectionName, java.util.Map<java.lang.String,java.util.List<Attrib>> attributeMap)
This method is responsible for building a list of RRDDataSource objects from the provided list of MBeanObject objects.- Parameters:
collectionName
- Collection nameattributeMap
- List of MBeanObject objects defining the attributes to be collected via JMX.- Returns:
- list of RRDDataSource objects
-
getRrdRepository
public RrdRepository getRrdRepository(java.lang.String collectionName)
Retrieve theRrdRepository
configuration for the given collection. This call will always be performed in OpenNMS.- Parameters:
collectionName
- aString
object.- Returns:
- a
RrdRepository
object.
-
setJmxConfigDao
public void setJmxConfigDao(JmxConfigDao jmxConfigDao)
-
setJmxDataCollectionConfigDao
public void setJmxDataCollectionConfigDao(JMXDataCollectionConfigDao jmxDataCollectionConfigDao)
-
-