use of org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQueryException in project opennms by OpenNMS.
the class JmxDatacollectionConfiggenerator method queryMbeanServer.
private QueryResult queryMbeanServer(List<String> ids, MBeanServerConnection mBeanServerConnection, boolean runStandardVmBeans) throws MBeanServerQueryException {
final MBeanServerQuery query = new MBeanServerQuery().withFilters(ids).fetchValues(// we do not fetch values to improve collection speed
false).showMBeansWithoutAttributes(// we don't need them
false).sort(// sorting makes finding attributes easier
true);
if (!runStandardVmBeans) {
query.withIgnoresFilter(Collections2.transform(standardVmBeans, input -> input + ":*"));
}
final QueryResult result = query.execute(mBeanServerConnection);
return result;
}
use of org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQueryException in project opennms by OpenNMS.
the class DetectMBeansJob method execute.
@Override
public JmxDatacollectionConfig execute() throws JobManager.TaskRunException {
final JmxConnectionConfig connectionConfig = new JmxConnectionConfigBuilder().withUrl(config.getConnection()).withUsername(config.getUser()).withPassword(config.getPassword()).build();
try (JmxServerConnectionWrapper connector = new DefaultJmxConnector().createConnection(connectionConfig)) {
final JmxDatacollectionConfiggenerator jmxConfigGenerator = new JmxDatacollectionConfiggenerator(new Slf4jLogAdapter(JmxDatacollectionConfiggenerator.class));
final JmxDatacollectionConfig generatedJmxConfigModel = jmxConfigGenerator.generateJmxConfigModel(connector.getMBeanServerConnection(), "anyservice", !config.isSkipDefaultVM(), config.isSkipNonNumber(), JmxHelper.loadInternalDictionary());
applyFilters(generatedJmxConfigModel);
return generatedJmxConfigModel;
} catch (IOException | MBeanServerQueryException | JMException | JmxServerConnectionException e) {
if (e instanceof UnknownHostException || e.getCause() instanceof UnknownHostException) {
throw new JobManager.TaskRunException(String.format("Unknown host: %s", config.getConnection()), e);
}
if (e instanceof MalformedURLException || e.getCause() instanceof MalformedURLException) {
throw new JobManager.TaskRunException(String.format("Cannot create valid JMX Connection URL. Connection: '%s'", config.getConnection()), e);
}
throw new JobManager.TaskRunException("Error while retrieving MBeans from server.", e);
}
}
use of org.opennms.features.jmxconfiggenerator.jmxconfig.query.MBeanServerQueryException in project opennms by OpenNMS.
the class JmxCommand method execute.
protected void execute() throws CmdLineException, CmdRunException {
try (JMXConnector connector = getJmxConnector()) {
MBeanServerConnection mbeanServerConnection = connector.getMBeanServerConnection();
execute(mbeanServerConnection);
} catch (MBeanServerQueryException | JMException | IOException e) {
throw new CmdRunException(e);
}
}
Aggregations