public MockGraph(Probe<?, ?> theStore) { super(theStore, new GraphDesc()); }
static public GraphDesc getGraphDesc() { GraphDesc gd = new GraphDesc(); gd.setGraphName("MokeGD"); return gd; }
public MockGraph() { super(new MokeProbe<String, Number>(), new GraphDesc()); }
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; }
public GraphDesc makeGraphDesc(JrdsDocument n) throws Exception { JrdsElement subnode = n.getRootElement(); GraphDesc gd = new GraphDesc();
@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; }
@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()); } }