@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(); }
protected GraphDesc getGraphDesc() { return node.getGraphDesc(); }
@Override public boolean acceptGraph(GraphNode graph, String path) { return (graph.getProbe() instanceof ContainerProbe); }
public boolean acceptGraph(GraphNode graph, String path) { boolean accepted = false; // An explicit graph is always accepted if(names.contains(graph.getQualifiedName())) accepted = true; // if neither tags or path, it's refused else if(!tags.isEmpty() || !goodPaths.isEmpty()) accepted = (acceptPath(path) && acceptTag(graph.getProbe())); if(logger.isTraceEnabled()) logger.trace(Util.delayedFormatString("Tried to accept : %s=%s, %s: %b", path, graph.getQualifiedName(), graph.getProbe() != null ? graph.getProbe().getTags() : "", accepted)); return accepted; }
public void addGraphs(Collection<GraphNode> graphs) { for(GraphNode currGraph: graphs) { LinkedList<String> path; path = currGraph.getTreePathByHost(); getGraphTreeByHost().addGraphByPath(path, currGraph); path = currGraph.getTreePathByView(); getGraphTreeByView().addGraphByPath(path, currGraph); graphMap.put(currGraph.hashCode(), currGraph); } }
logger.trace("Tree found: " + graphTree.getName()); for(GraphNode gn: graphTree.enumerateChildsGraph(null)) { if(!done.contains(gn.hashCode())) { 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()); try { r.render(g); } catch (Exception e) { logger.error("Error " + e + " with " + gn.getGraphTitle());
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); }
message = String.format("Error rendering graph %s: %s", graphName, e.getMessage()); } catch (Exception e1) { String graphName = graph.getNode().getProbe().getName() + "/" + graph.getNode().getGraphDesc().getGraphName(); message = String.format("Error rendering incomplete graph %s: %s", graphName, e.getMessage());
if(getPropertiesManager().security && !child.getACL().check(params)) continue; String leafName = leaf.getKey(); if(f.acceptGraph(child, gt.getPath() + "/" + child.getName())) { hasChild = true; String graphid = base + "." + child.hashCode(); childsref.add(graphid); doTree(w, leafName, graphid, "graph", null);
String qualifiedGraphName = gn.getQualifiedName(); Element graph = (Element) graphs.appendChild(document.createElement("graphname")); graph.setTextContent(qualifiedGraphName); graph.setAttribute("id", String.valueOf(gn.hashCode()));
public void addGraph(GraphDesc gd) { graphList.add(new GraphNode(this, gd)); }
@Override public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + end.hashCode(); result = PRIME * result + start.hashCode(); long temp; temp = Double.doubleToLongBits(max); result = PRIME * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(min); result = PRIME * result + (int) (temp ^ (temp >>> 32)); result = PRIME * result + ((node == null) ? 0 : node.hashCode()); return result; }
protected void fillGraphDef(RrdGraphDef graphDef) { GraphDesc gd = getGraphDesc(); try { long startsec = getStartSec(); long endsec = getEndSec(); ExtractInfo ei = ExtractInfo.get().make(start, end); graphDef.setStartTime(startsec); graphDef.setEndTime(endsec); PlottableMap customData = node.getCustomData(); if(customData != null) { long step = Math.max((endsec - startsec) / gd.getWidth(), 1); customData.configure(startsec, endsec, step); } setGraphDefData(graphDef, node.getProbe(), ei, customData); if(gd.withLegend()) addlegend(graphDef); } catch (RuntimeException e) { Util.log(this, logger, Level.ERROR, e, "Impossible to create graph definition: %s", e.getMessage()); } }
dp = g.getPlottedDate(ei); } catch (IOException e) { logger.error("Failed to read " + g.getProbe()); continue; Extractor ex = g.getProbe().fetchData(); ex.fill(dp, ei); ex.release();
/** * Return a uniq name for the graph * * @return */ public String getQualifiedName() { return node.getQualifiedName(); }
public String getPngName() { return node.getName().replaceAll("/", "_").replaceAll(" ", "_") + ".png"; }
public String resolve(GraphNode graph) { return graph.getGraphTitle(); } },
public GraphNode getGraphNode(JrdsServlet caller) { GraphNode gn = null; if(id != null) gn = hostlist.getGraphById(id); if(gn != null) { logger.debug(jrds.Util.delayedFormatString("Graph found: %s", gn)); } else if(pid != null && pid != 0 && dsName != null) { if(!caller.allowed(this, hostlist.getDefaultRoles())) return null; Probe<?, ?> p = getProbe(); if(p == null) { logger.error("Looking for unknown probe"); return null; } logger.debug(jrds.Util.delayedFormatString("Probe found: %s", p)); Graphics2D g2d = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).createGraphics(); String graphDescName = p.getName() + "." + dsName; GraphDesc gd = new GraphDesc(); gd.setName(graphDescName); gd.setGraphName(p.getHost().getName() + "." + p.getName() + "." + dsName); gd.setGraphTitle(p.getName() + "." + dsName + " on ${host}"); gd.add(dsName, GraphDesc.LINE); gd.initializeLimits(g2d); gn = new GraphNode(p, gd); gn.addACL(Configuration.get().getPropertiesManager().defaultACL); } return gn; }