@Test public void testDefault() throws IOException { PropertiesManager pm = Tools.makePm(testFolder, "tabs=filtertab,customgraph,@,sumstab,servicestab,viewstab,hoststab,tagstab,adminTab"); HostsList hl = new HostsList(pm); Assert.assertEquals("First tab not found", pm.tabsList.get(0), hl.getFirstTab()); Assert.assertEquals("Missing tabs", pm.tabsList.size() - optionalstabs.length, hl.getTabsId().size()); }
public void addProbe(Probe<?, ?> p) { probeMap.put(p.hashCode(), p); addGraphs(p.getGraphList()); }
log(Level.ERROR, "Probes directory not configured, can't configure"); return; log(Level.ERROR, "Configuration directory not configured, can't configure"); return; setTimeout(pm.timeout); setStep(pm.step); log(Level.TRACE, "timers to build %s", pm.timers); log(Level.DEBUG, "timers %s", timers); log(Level.DEBUG, "Starting parsing descriptions"); ConfigObjectFactory conf = new ConfigObjectFactory(pm); conf.setArchiveSetMap(); for(ProbeDesc<?> pd: allProbeDesc.values()) { for(ProbeMeta meta: ArgFactory.enumerateAnnotation(pd.getProbeClass(), ProbeMeta.class, StarterNode.class)) { log(Level.TRACE, "new probe meta: %s", meta); daList.add(meta.discoverAgent()); log(Level.DEBUG, "Discover agents classes are %s", daList); conf.setMacroMap(); for(Listener<?, ?> l: conf.setListenerMap().values()) { registerStarter(l); topStarters.add(l); try {
public void start(String[] args) throws Exception { PropertiesManager pm = new PropertiesManager(new File(propFile)); jrds.JrdsLoggerConfiguration.configure(pm); System.getProperties().setProperty("java.awt.headless", "true"); System.getProperties().putAll(pm); HostsList hl = new HostsList(pm); logger.debug("Scanning dir"); for(Timer t: hl.getTimers()) { t.collectAll(); } }
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); } }
String tabName = getValue("tab"); if(paramFilterName != null && !"".equals(paramFilterName)) { filter = hostlist.getFilter(paramFilterName); choiceType = FILTERCHOICE; choiceValue = paramFilterName; } else if(paramHostFilter != null && !"".equals(paramHostFilter)) { tree = hl.getGraphTreeByHost().getByPath(GraphTree.HOSTROOT, paramHostFilter); choiceType = HOSTCHOICE; choiceValue = paramHostFilter; } else if(treeName != null && !"".equals(treeName)) { tree = hl.getGraphTree(treeName); choiceType = TREECHOICE; choiceValue = treeName; } else if(tabName != null && !"".equals(tabName)) { tab = hl.getTab(tabName); choiceType = TABCHOICE; choiceValue = tabName; tab = hl.getTab(choiceValue); choiceValue = hostlist.getFirstTab(); choiceType = TABCHOICE;
propertiesManager.importSystemProps(); propertiesManager.update(); HostsList hostsList = new HostsList(propertiesManager); GraphTree gt = hostsList.getGraphTreeByHost(); for (GraphNode gn: gt.enumerateChildsGraph()) { GraphDesc gd = gn.getGraphDesc(); long step = 100; ExtractInfo ei = ExtractInfo.get().make(ConsolFun.AVERAGE).make(start, now).make(step); for (HostInfo hi: hostsList.getHosts()) { System.out.println(hi.getName()); for (Probe<?, ?> p: hi.getProbes()) {
private Configuration(Properties p) { propertiesManager.join(p); propertiesManager.importSystemProps(); propertiesManager.update(); hostsList = new HostsList(propertiesManager); }
@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); } }
@Test(expected = RuntimeException.class) public void emptysum() throws Exception { HostsList hl = new HostsList(); hl.configure(new PropertiesManager()); ArrayList<String> graphlist = new ArrayList<String>(); graphlist.add("badhost/badgraph"); Sum s = new Sum("emptysum", graphlist); s.configure(hl); }
@Test public void testTagsTab() throws IOException { PropertiesManager pm = Tools.makePm(testFolder); pm.setProperty("tabs", "filtertab"); pm.update(); HostsList hl = new HostsList(pm); Set<String> hostsTags = Collections.singleton("tag"); Set<Tab> tabs = new HashSet<Tab>(); hl.doTagsTabs(hostsTags, tabs); Tab tab = (Tab) tabs.toArray()[0]; Assert.assertTrue(tab.isFilters()); }
Collection<HostInfo> hosts = hl.getHosts(); int numHosts = hosts.size(); int numProbes = 0; int generation = hl.getGeneration(); for(HostInfo h: hosts) { numProbes += h.getNumProbes(); for(Timer t: hl.getTimers()) { try { stats.put(t.getName(), (Stats) t.getStats().clone());
private Sum doSum(JrdsDocument d, HostsList hl) throws Exception { HostInfo host = new HostInfo("SumHost"); SumBuilder sm = new SumBuilder(); sm.setPm(Tools.makePm(testFolder, "security=yes")); Sum sp = sm.makeSum(d); try { sp.configure(hl); } catch (Exception e) { } sp.getProbe().setHost(new HostStarter(host)); hl.addHost(host); hl.addProbe(sp.getProbe()); jrds.GraphNode mg = new MockGraph(); mg.getGraphDesc().add("plot"); hl.addHost(mg.getProbe().getHost()); hl.addProbe(mg.getProbe()); return sp; }
@Override public int getHostsCount() { HostsList hl = Configuration.get().getHostsList(); Collection<HostInfo> hosts = hl.getHosts(); return hosts.size(); }
@Test public void testHostList1() { HostsList hl = new HostsList(); StarterNode n2 = new StarterNode(hl) { }; StarterNode n3 = new StarterNode(n2) { }; Assert.assertEquals(hl, n3.getHostList()); }