@Override public Graph getGraph() { PlottableMap pp = new PlottableMap() { @Override public void configure(long start, long end, long step) { try (RRDatabase db = new RRDatabase(rrdpath)){ DataChunk chunck = db.getData(ConsolidationFunctionType.AVERAGE, start, end, step); for(String name: db.getDataSourcesName()) { put(name, chunck.toPlottable(name)); } } catch (IOException e) { throw new RuntimeException("Unable to create ProxyPlottableMap", e); } } }; setCustomData(pp); return super.getGraph(); }
done.add(gn.hashCode()); logger.debug("New graph: " + gn.getGraphTitle()); Graph g = gn.getGraph(); g.setPeriod(p); logger.debug("Found graph for probe " + gn.getProbe());
public jrds.Graph getGraph(JrdsServlet caller) { jrds.Graph g = null; if(gid != null) g = hostlist.getRenderer().getGraph(gid); if(g == null) { logger.debug("graph cache miss"); jrds.GraphNode node = getGraphNode(caller); if(node != null) { g = node.getGraph(); configureGraph(g); } } return g; }
private void doGraph(GraphNode gn, Renderer r, ParamsBean params, JrdsJSONWriter w) throws IOException { jrds.Graph graph = gn.getGraph(); if (graph == null) { return; } params.configureGraph(graph); Map<String, Object> imgProps = new HashMap<String, Object>(); r.render(graph); Probe<?, ?> p = gn.getProbe(); imgProps.put("probename", p.getName()); imgProps.put("qualifiedname", graph.getQualifiedName()); Dimension d = graph.getDimension(); if(d != null) { imgProps.put("height", d.height); imgProps.put("width", d.width); } imgProps.put("graph", params.doArgsMap(graph, true)); imgProps.put("history", params.doArgsMap(graph, false)); imgProps.put("probe", params.doArgsMap(p, true)); imgProps.put("graphnode", params.doArgsMap(gn, true)); doTree(w, graph.getQualifiedName(), gn.hashCode(), "graph", null, imgProps); }
@Test public void test1() throws IOException, InvocationTargetException { RRDToolProbe p = new RRDToolProbe(); p.setHost(new HostStarter(new HostInfo("toto"))); ProbeDesc<String> pd = new ProbeDesc<String>(); pd.setName("Rrdtool"); pd.setProbeName("rrdtool"); p.setPd(pd); Map<String, String> empty = Collections.emptyMap(); p.setMainStore(new RrdDbStoreFactory(), empty); Assert.assertTrue("rrd native file can't be read", rrdfile.canRead()); Assert.assertTrue("Configuration of the probe failed", p.configure(rrdfile)); Assert.assertTrue("Check of the probe failed", p.checkStore()); GraphDesc gd = new GraphDesc(); gd.setGraphName("rrdtool"); gd.setName("rrdtool"); gd.add("speed", "speed", null, GraphDesc.LINE, Color.BLUE, "speed", GraphDesc.DEFAULTCF, false, null, null, null); gd.add("weight", "weight", null, GraphDesc.LINE, Color.GREEN, "weight", GraphDesc.DEFAULTCF, false, null, null, null); p.addGraph(gd); for(GraphNode gn: p.getGraphList()) { Graph g = gn.getGraph(); g.setEnd(new Date(end * 1000)); g.setStart(new Date(start * 1000)); File outputFile = new File(testFolder.getRoot(), "rrdtool.png"); OutputStream out = new FileOutputStream(outputFile); g.writePng(out); Assert.assertTrue("graph not created", outputFile.canRead()); } }