use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.
the class JMXDataCollectionConfigDao method getStep.
public int getStep(String cName) {
// Try retrieving the object, which will trigger a reload of the cache if it changed
getObject();
m_lock.readLock().lock();
try {
JmxCollection collection = m_collectionMap.get(cName);
if (collection != null)
return collection.getRrd().getStep();
else
return -1;
} finally {
m_lock.readLock().unlock();
}
}
use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.
the class JMXDataCollectionConfigDao method getMBeanInfo.
public Map<String, BeanInfo> getMBeanInfo(String cName) {
// Try retrieving the object, which will trigger a reload of the cache if it changed
getObject();
m_lock.readLock().lock();
try {
Map<String, BeanInfo> map = new HashMap<String, BeanInfo>();
// Retrieve the appropriate Collection object
//
JmxCollection collection = m_collectionMap.get(cName);
if (collection == null) {
LOG.warn("no collection named '{}' was found", cName);
} else {
return getMBeanInfo(collection);
}
return Collections.unmodifiableMap(map);
} finally {
m_lock.readLock().unlock();
}
}
use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.
the class JMXCollector method getRuntimeAttributes.
@Override
public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) {
final Map<String, Object> runtimeAttributes = new HashMap<>();
// Retrieve the name of the JMX data collector
final String collectionName = ParameterMap.getKeyedString(parameters, ParameterName.COLLECTION.toString(), serviceName);
final JmxCollection jmxCollection = m_jmxDataCollectionConfigDao.getJmxCollection(collectionName);
if (jmxCollection == null) {
throw new IllegalArgumentException(String.format("JMXCollector: No collection found with name '%s'.", collectionName));
}
runtimeAttributes.put(JMX_COLLECTION_KEY, jmxCollection);
// Retrieve the agent config.
final Map<String, String> parameterStringMap = new HashMap<String, String>();
for (Map.Entry<String, Object> eachEntry : parameters.entrySet()) {
if (eachEntry.getValue() instanceof String) {
parameterStringMap.put(eachEntry.getKey(), (String) eachEntry.getValue());
}
}
final MBeanServer mBeanServer = JmxUtils.getMBeanServer(m_jmxConfigDao, agent.getHostAddress(), parameterStringMap);
if (mBeanServer != null) {
runtimeAttributes.put(JMX_MBEAN_SERVER_KEY, mBeanServer);
}
return runtimeAttributes;
}
use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.
the class JmxDatacollectionConfiggenerator method createJmxDataCollectionConfig.
private JmxDatacollectionConfig createJmxDataCollectionConfig(String serviceName, Rrd rrd) {
final JmxDatacollectionConfig xmlJmxDatacollectionConfig = new JmxDatacollectionConfig();
final JmxCollection xmlJmxCollection = new JmxCollection();
xmlJmxCollection.setName("JSR160-" + serviceName);
xmlJmxCollection.setRrd(rrd);
xmlJmxDatacollectionConfig.addJmxCollection(xmlJmxCollection);
return xmlJmxDatacollectionConfig;
}
use of org.opennms.netmgt.config.collectd.jmx.JmxCollection in project opennms by OpenNMS.
the class JmxDatacollectionConfiggenerator method generateJmxConfigModel.
public JmxDatacollectionConfig generateJmxConfigModel(List<String> ids, MBeanServerConnection mBeanServerConnection, String serviceName, Boolean runStandardVmBeans, Boolean skipNonNumber, Map<String, String> dictionary) throws MBeanServerQueryException, IOException, JMException {
logger.debug("Startup values: \n serviceName: " + serviceName + "\n runStandardVmBeans: " + runStandardVmBeans + "\n dictionary" + dictionary);
aliasList.clear();
aliasMap.clear();
nameCutter.setDictionary(dictionary);
final QueryResult queryResult = queryMbeanServer(ids, mBeanServerConnection, runStandardVmBeans);
final JmxDatacollectionConfig xmlJmxDatacollectionConfig = createJmxDataCollectionConfig(serviceName, rrd);
final JmxCollection xmlJmxCollection = xmlJmxDatacollectionConfig.getJmxCollectionList().get(0);
for (QueryResult.MBeanResult eachMBeanResult : queryResult.getMBeanResults()) {
final ObjectName objectName = eachMBeanResult.objectName;
final Mbean xmlMbean = createMbean(objectName);
final QueryResult.AttributeResult attributeResult = eachMBeanResult.attributeResult;
for (MBeanAttributeInfo jmxBeanAttributeInfo : attributeResult.attributes) {
// check for CompositeData
if ("javax.management.openmbean.CompositeData".equals(jmxBeanAttributeInfo.getType())) {
CompAttrib compAttrib = createCompAttrib(mBeanServerConnection, objectName, jmxBeanAttributeInfo, skipNonNumber);
if (compAttrib != null) {
xmlMbean.addCompAttrib(compAttrib);
}
}
if (skipNonNumber && !numbers.contains(jmxBeanAttributeInfo.getType())) {
logger.warn("The type of attribute '{}' is '{}' and '--skipNonNumber' is set. Ignoring.", jmxBeanAttributeInfo.getName(), jmxBeanAttributeInfo.getType());
} else {
Attrib xmlJmxAttribute = createAttr(jmxBeanAttributeInfo);
xmlMbean.addAttrib(xmlJmxAttribute);
}
}
if (!xmlMbean.getAttribList().isEmpty() || !xmlMbean.getCompAttribList().isEmpty()) {
xmlJmxCollection.addMbean(xmlMbean);
}
}
if (xmlJmxCollection.getMbeans().size() != queryResult.getMBeanResults().size()) {
logger.warn("Queried {} MBeans, but only got {} in the result set.", queryResult.getMBeanResults().size(), xmlJmxCollection.getMbeans().size());
}
return xmlJmxDatacollectionConfig;
}
Aggregations