@Override String toString(Object o) { return ((Probe<?, ?>) o).getName(); } },
public String getPrefix(Probe<?, ?> probe) { String pname = probe.getName(); String hostname = probe.getHost().getName(); if(hostname.contains(".")) { String[] part = hostname.split("\\."); StringBuilder b = new StringBuilder(hostname.length()); for(int i = part.length - 1; i >= 0; i--) { b.append(part[i]); b.append("."); } hostname = b.toString(); } else { hostname = hostname + "."; } if(pname.contains(".")) { pname = pname.replace('.', '_'); } return commonPrefix + hostname + pname; }
@Override public CacheStore create(Probe<?, ?> p) { String hostname = p.getHost().getName(); String probeName = p.getName(); if(!cache.containsKey(hostname)) cache.put(hostname, new HashMap<String, Map<String, Number>>()); Map<String, Map<String, Number>> probes = cache.get(hostname); if(!probes.containsKey(probeName)) probes.put(probeName, new HashMap<String, Number>(p.getPd().getDsDefs().length)); return new CacheStore(p, probes.get(probeName)); }
/** * Return a unique name for the graph * * @return */ public String getQualifiedName() { return getHost().getName() + "/" + getName(); }
public String getPath() { String rrdName = p.getName().replaceAll("/", "_"); return p.getHost().getHostDir() + Util.getFileSeparator() + rrdName + ".rrd"; }
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; }
/** * Return the string value of the probe as a path constituted of the host * name / the probe name * * @see java.lang.Object#toString() */ public String toString() { String hn = "<empty>"; if(getHost() != null) hn = getHost().getName(); return hn + "/" + getName(); }
public Document dumpAsXml(boolean sorted) throws ParserConfigurationException, IOException { String probeName = getPd().getName(); String name = getName(); String host = ""; if(getHost() != null)
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());
tpool.execute(runUpgrade); } catch (RejectedExecutionException ex) { logger.debug("collector thread dropped for probe " + p.getName());
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); }
String name = p.getName(); if(name == null) name = jrds.Util.parseTemplate(p.getPd().getProbeName(), p);
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; }
try { sourceDp = probe.extract(ei); fileName = probe.getName().replaceFirst("\\.rrd", ".csv"); } catch (IOException e) { logger.error("Unable to process probe data");
System.out.println(hi.getName()); for (Probe<?, ?> p: hi.getProbes()) { System.out.println(" " + p.getName()); try (Extractor ex = p.fetchData()) { for (String dsName: p.getPd().getDs()) {
public void collectAll() { log(Level.DEBUG, "Starting collect"); Timer timer = (Timer) getParent(); long start = System.currentTimeMillis(); startCollect(); String oldThreadName = Thread.currentThread().getName(); for(Probe<?, ?> probe: allProbes) { if(!isCollectRunning()) break; long duration = (System.currentTimeMillis() - start) / 1000; if(duration > (probe.getStep() / 2)) { log(Level.ERROR, "Collect too slow: %ds for timer %s", duration, timer); break; } log(Level.TRACE, "Starting collect for %s", probe); log(Level.DEBUG, "Collect all stats for host " + host.getName()); setRunningname(oldThreadName + "/" + probe.getName()); probe.collect(); setRunningname(oldThreadName + ":finished"); } stopCollect(); long end = System.currentTimeMillis(); float elapsed = (end - start) / 1000f; log(Level.DEBUG, "Collect time for %s: %fs", host.getName(), elapsed); }
if (p != null) { Optional.ofNullable(p.getQualifiedName()).ifPresent( i -> w.key("probequalifiedname").value(i)); Optional.ofNullable(p.getName()).ifPresent( i-> w.key("probeinstancename").value(i)); Optional.ofNullable(p.getPd().getName()).ifPresent( i-> w.key("probename").value(i)); Optional.ofNullable(p.getHost().getName()).ifPresent( i-> w.key("hostname").value(i));
@Test public void testProbe2() throws Exception { JrdsDocument d = Tools.parseString(goodProbeXml2); PropertiesManager pm = Tools.makePm(testFolder); HostBuilder hb = new HostBuilder(); hb.setProbeFactory(new MokeProbeFactory()); hb.setPm(pm); hb.setTimers(Tools.getSimpleTimerMap()); HostInfo host = new HostInfo("testProbe2"); host.setHostDir(pm.rrddir); Probe<?, ?> p = hb.makeProbe(d.getRootElement(), host, null); Assert.assertNotNull(p); Assert.assertEquals(host.getName() + "/" + p.getName(), p.toString()); }
logger.trace(p.getName());