public Set<String> getTags() { return getHost().getTags(); }
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 boolean acceptGraph(GraphNode graph, String path) { HostInfo host = graph.getProbe().getHost(); return (!host.isHidden()) && path.startsWith("/" + GraphTree.HOSTROOT + "/"); }
@Override public boolean acceptGraph(GraphNode graph, String path) { return graph.getProbe().getHost().getName().equals(hostname) && path.startsWith("/" + GraphTree.HOSTROOT + "/"); }
@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 static Object makeKey(StarterNode node) { HostInfo host; if(node instanceof HostStarter) host = ((HostStarter) node).getHost(); else if(node instanceof Probe<?, ?>) { Probe<?, ?> p = (Probe<?, ?>) node; host = p.getHost(); } else { return null; } return "resolver:" + host.getDnsName(); }
@Override public boolean acceptGraph(GraphNode graph, String path) { Probe<?, ?> p = graph.getProbe(); if(p == null) return false; HostInfo host = p.getHost(); if(host == null) return false; Set<String> hostTags = graph.getProbe().getHost().getTags(); if(hostTags == null) { return false; } for(String oneTag: hostTags) { if(tag.equals(oneTag)) return true; } return false; }
public String resolve(GraphNode graph) { return graph.getProbe().getHost().getName(); } },
public String getPath() { String rrdName = p.getName().replaceAll("/", "_"); return p.getHost().getHostDir() + Util.getFileSeparator() + rrdName + ".rrd"; }
public LinkedList<String> getTree(GraphNode graph, String tabname) { List<?> elementsTree = trees.get(tabname); LinkedList<String> tree = new LinkedList<String>(); if(elementsTree == null) return tree; for(Object o: elementsTree) { if(o instanceof String) { String pathElem = jrds.Util.parseTemplate((String) o, graph.getProbe(), this, graph.getProbe().getHost()); tree.add(pathElem); } else if(o instanceof PathElement) tree.add(((PathElement) o).resolve(graph)); } return tree; }
private boolean resolveDefaultBean(Probe<?, ?> p, List<Object> args, Map<String, String> properties, String beanName, String beanValue) { HostInfo host = p.getHost(); ProbeDesc<?> pd = p.getPd(); GenericBean bean = pd.getBean(beanName);
/** * Return the host name associated * * @return */ public String getHostName() { StarterNode level = getLevel(); if(level instanceof HostStarter) { return ((HostStarter) level).getDnsName(); } if(level instanceof Probe<?, ?>) { return ((Probe<?, ?>) level).getHost().getDnsName(); } return null; }
/** * Check the final status of the probe. It must be called once before an * probe can be used * * Open the rrd backend of the probe. it's created if it's needed * */ public boolean checkStore() { ProbeDesc<KeyType> pd = getPd(); if(pd == null) { log(Level.ERROR, "Missing Probe description"); return false; } if(getHost() == null) { log(Level.ERROR, "Missing host"); return false; } // Name can be set by other means if(name == null) name = parseTemplate(pd.getProbeName()); finished = mainStore.checkStoreFile(archives); return finished; }
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; }
p.addGraph(gd); hl.addHost(p.getHost()); hl.addProbe(p);
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; }