Search in sources :

Example 1 with JmxConfigReader

use of org.opennms.features.jmxconfiggenerator.graphs.JmxConfigReader in project opennms by OpenNMS.

the class GraphCreateCommand method execute.

@Override
protected void execute() throws CmdRunException, CmdLineException {
    if (printTemplate) {
        LOG.info(getClass().getResourceAsStream("/graphTemplate.vm"));
        return;
    }
    try {
        JmxConfigReader jmxToSnmpGraphConfigGen = new JmxConfigReader(LOG);
        Collection<Report> reports = jmxToSnmpGraphConfigGen.generateReportsByJmxDatacollectionConfig(inputFile);
        GraphConfigGenerator graphConfigGenerator = new GraphConfigGenerator(LOG);
        String snmpGraphConfig = graphConfigGenerator.generateSnmpGraph(reports, templateFile);
        LOG.info(snmpGraphConfig);
        ByteStreams.copy(new ByteArrayInputStream(snmpGraphConfig.getBytes()), new FileOutputStream(outFile));
    } catch (IOException ioex) {
        throw new CmdRunException(ioex);
    }
}
Also used : JmxConfigReader(org.opennms.features.jmxconfiggenerator.graphs.JmxConfigReader) Report(org.opennms.features.jmxconfiggenerator.graphs.Report) ByteArrayInputStream(java.io.ByteArrayInputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) GraphConfigGenerator(org.opennms.features.jmxconfiggenerator.graphs.GraphConfigGenerator)

Example 2 with JmxConfigReader

use of org.opennms.features.jmxconfiggenerator.graphs.JmxConfigReader 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;
}
Also used : JmxConfigReader(org.opennms.features.jmxconfiggenerator.graphs.JmxConfigReader) Report(org.opennms.features.jmxconfiggenerator.graphs.Report) Slf4jLogAdapter(org.opennms.features.jmxconfiggenerator.log.Slf4jLogAdapter) GraphConfigGenerator(org.opennms.features.jmxconfiggenerator.graphs.GraphConfigGenerator)

Aggregations

GraphConfigGenerator (org.opennms.features.jmxconfiggenerator.graphs.GraphConfigGenerator)2 JmxConfigReader (org.opennms.features.jmxconfiggenerator.graphs.JmxConfigReader)2 Report (org.opennms.features.jmxconfiggenerator.graphs.Report)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 Slf4jLogAdapter (org.opennms.features.jmxconfiggenerator.log.Slf4jLogAdapter)1