use of org.opennms.features.jmxconfiggenerator.log.Slf4jLogAdapter in project opennms by OpenNMS.
the class GenerateConfigsJob method execute.
@Override
public Void execute() throws JobManager.TaskRunException {
// create snmp-graph.properties
GraphConfigGenerator graphConfigGenerator = new GraphConfigGenerator(new Slf4jLogAdapter(GraphConfigGenerator.class));
Collection<Report> reports = new JmxConfigReader(new Slf4jLogAdapter(JmxConfigReader.class)).generateReportsByJmxDatacollectionConfig(model.getOutputConfig());
model.setSnmpGraphProperties(graphConfigGenerator.generateSnmpGraph(reports));
model.updateOutput();
return null;
}
use of org.opennms.features.jmxconfiggenerator.log.Slf4jLogAdapter in project opennms by OpenNMS.
the class JmxDatacollectionConfiggeneratorTest method setUp.
@Before
public void setUp() throws Exception {
jmxConfiggenerator = new JmxDatacollectionConfiggenerator(new Slf4jLogAdapter(JmxDatacollectionConfiggenerator.class));
platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
testObjectName = new ObjectName("org.opennms.tools.jmxconfiggenerator.jmxconfig:type=JmxTest");
testMBean = new JmxTestDummy();
platformMBeanServer.registerMBean(testMBean, testObjectName);
}
use of org.opennms.features.jmxconfiggenerator.log.Slf4jLogAdapter 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.log.Slf4jLogAdapter in project opennms by OpenNMS.
the class GraphConfigGeneratorTest method verifyGraphGeneration.
@Test
public void verifyGraphGeneration() {
JmxConfigReader jmxConfigReader = new JmxConfigReader(new Slf4jLogAdapter(JmxConfigReader.class));
Collection<Report> reports = jmxConfigReader.generateReportsByJmxDatacollectionConfig(getClass().getResourceAsStream("/cassandra21x-datacollection-config.xml"));
GraphConfigGenerator graphConfigGenerator = new GraphConfigGenerator(new Slf4jLogAdapter(GraphConfigGenerator.class));
String snmpGraph = graphConfigGenerator.generateSnmpGraph(reports);
Assert.assertNotNull(snmpGraph);
}
Aggregations