public void configure(HostsList hl) { super.configure(hl); this.hl = hl; GraphNode g = null; // Check the sum consistency for(String graphname: graphList) { g = hl.getGraphById(graphname.hashCode()); if(g == null) { logger.warn(Util.delayedFormatString("graph %s not found for sum '%s'", graphname, getName())); } } // The last graph found is used to clone the graphdesc and use it if(g != null) { try { GraphDesc oldgd = g.getGraphDesc(); GraphDesc newgd = (GraphDesc) oldgd.clone(); newgd.setGraphTitle(getName()); setGraphDesc(newgd); logger.debug(Util.delayedFormatString("Adding sum called %s", getQualifiedName())); } catch (CloneNotSupportedException e) { throw new RuntimeException(String.format("GraphDesc is supposed to be clonnable, what happened with %s ?", getName())); } } else { throw new RuntimeException(String.format("Not graph found in %s definition, unusable sum", getName())); } }
public AutoGraph(Probe<?, ?> theStore, Operation op) { super(theStore, new GraphDesc() { String name = "autograph" + i++; /* * (non-Javadoc) * * @see jrds.GraphDesc#getGraphName() */ @Override public String getGraphName() { return name; } }); GraphDesc gd = this.getGraphDesc(); gd.setGraphName(theStore.getName()); gd.setGraphTitle(theStore.getName()); gd.setName(theStore.getName()); gd.setTree(PropertiesManager.HOSTSTAB, Arrays.<Object> asList(GraphDesc.TITLE)); logger.debug(this.getQualifiedName()); this.op = op; }
public Sum(String name, ArrayList<String> graphList) { super(name); this.graphList = graphList; GraphDesc gd = new GraphDesc(); gd.setGraphName(name); gd.setGraphTitle(name); gd.setName(name); setGraphDesc(gd); getProbe().addGraph(this); }
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; }
@Test public void testCustomGraph() throws IOException { PropertiesManager pm = Tools.makePm(testFolder); pm.setProperty("tabs", "filtertab"); pm.update(); HostsList hl = new HostsList(pm); GraphDesc gd = new GraphDesc(); gd.setName("truc"); gd.setGraphTitle("title"); Map<String, GraphDesc> gdmap = new HashMap<String, GraphDesc>(); gdmap.put(gd.getName(), gd); Set<Tab> tabs = new HashSet<Tab>(); Map<Integer, GraphNode> graphMap = new HashMap<Integer, GraphNode>(); Map<String, GraphTree> graphTrees = new HashMap<String, GraphTree>(); hl.doCustomGraphs(gdmap, graphMap, graphTrees, tabs); hl.addGraphs(graphMap.values()); boolean found = false; GraphNode node = null; for(Tab t: tabs) { if(PropertiesManager.CUSTOMGRAPHTAB.equals(t.id)) { found = true; t.setHostlist(hl); node = t.getGraphTree().enumerateChildsGraph().get(0); } } Assert.assertNotNull(graphMap.get(node.hashCode())); Assert.assertTrue(found); Assert.assertNotEquals(graphTrees.size(), 0); } }
static public GraphDesc getGd() { GraphDesc gd = new GraphDesc(); gd.add("sun", null, GraphDesc.LINE.toString(), "green", null, null, null, null, null, null, null); gd.add("shade", null, GraphDesc.LINE.toString(), "blue", null, null, null, null, null, null, null); gd.add("median", "sun,shade,+,2,/", GraphDesc.LINE.toString(), "magenta", null, null, null, null, null, null, null); gd.add("diff", "sun,shade,-,ABS,-1,*", GraphDesc.AREA.toString(), "yellow", null, null, null, null, null, null, null); gd.setGraphTitle("Temperatures in May 2003"); gd.setVerticalLabel("temperature"); return gd; }