public void start(String[] args) throws Exception { ProbeDesc<OID> pd = new ProbeDesc<>(); pd.setProbeClass(jrds.probe.snmp.RdsSnmpSimple.class); boolean indexed = false; for(int i = 0; i < args.length; i++) { OidInfo info = translate(args[++i]); pd.setProbeClass(jrds.probe.snmp.RdsIndexedSnmpRrd.class); pd.addSpecific(RdsIndexedSnmpRrd.INDEXOIDNAME, info.oid.toString()); indexed = true; @SuppressWarnings("unchecked") Class<? extends Probe<OID, ?>> c = (Class<? extends Probe<OID, ?>>)Class.forName(args[++i]); pd.setProbeClass(c); } else if("--graphs".equals(cmd.toLowerCase())) { String graphsList = args[++i];
@Override public Probe<?, ?> makeProbe(String type) { logger.trace(type); ProbeDesc<String> pd = generateProbeDesc(type); try { pd.setProbeClass(MokeProbeBean.class); } catch (InvocationTargetException e1) { throw new RuntimeException(e1); } Probe<?, ?> p = new MokeProbeBean(pd); try { pd.addDefaultBean("hostInfo", "${host}", false); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } return p; } });
public void start(String[] args) throws Exception { ProbeDesc<OID> pd = new ProbeDesc<>(); pd.setProbeClass(jrds.probe.snmp.RdsSnmpSimple.class); List<String> xmlPaths = new ArrayList<>(); MibLoader loader = new MibLoader();
@Test public void enumerateProbe() throws IOException { PropertiesManager pm = Tools.makePm(testFolder, "autocreate=false", "strictparsing=true"); pm.update(); pm.libspath.clear(); File descpath = new File("desc"); if(descpath.exists()) pm.libspath.add(descpath.toURI()); ConfigObjectFactory conf = new ConfigObjectFactory(pm); Set<String> failed = new HashSet<String>(); for(JrdsDocument n: conf.getNodeMap(ConfigType.PROBEDESC).values()) { JrdsElement root = n.getRootElement(); JrdsElement classElem = root.getElementbyName("probeClass"); ProbeDesc<String> pd = new ProbeDesc<>(); String name = ""; try { String className = classElem.getTextContent().trim(); name = root.getElementbyName("name").getTextContent(); @SuppressWarnings("unchecked") Class<? extends Probe<String, ?>> c = (Class<? extends Probe<String, ?>>) pm.extensionClassLoader.loadClass(className); pd.setProbeClass(c); } catch (Exception e) { logger.error("Failed probedesc " + name + ": " + e.getMessage()); failed.add(name); } } if(!failed.isEmpty()) { Assert.fail("Invalid class:" + failed); } }
pd.setProbeClass((Class<? extends Probe<A, B>>) this.getClass()); } catch (InvocationTargetException e) { throw new RuntimeException("Can't build moke probe", e);
pd.setProbeClass((Class<? extends Probe<KeyType, ?>>) c);
@SuppressWarnings("unchecked") @Test public void build5() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { HttpProbe<String> p = new HttpProbe<String>() { @Override protected Map<String, Number> parseStream(InputStream stream) { return null; } }; ProbeDesc<String> pd = new ProbeDesc<String>(); pd.setProbeClass((Class<? extends Probe<String, ?>>) p.getClass()); p.setHost(webserver); p.setPd(pd); p.setFile("/${1}"); p.setPort(80); List<Object> args = Arrays.asList((Object) "file"); Assert.assertTrue(p.configure(args)); Assert.assertEquals("http://" + HOST + ":80/file", p.getUrlAsString()); validateBean(p); }
@SuppressWarnings("unchecked") @Test public void build2() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { HttpProbe<String> p = new HttpProbe<String>() { @Override protected Map<String, Number> parseStream(InputStream stream) { return null; } }; p.setHost(webserver); ProbeDesc<String> pd = new ProbeDesc<String>(); pd.setProbeClass((Class<? extends Probe<String, ?>>) p.getClass()); p.setPd(pd); p.setFile("/file"); p.setPort(80); Assert.assertTrue(p.configure("/file")); Assert.assertEquals("http://" + HOST + ":80/file", p.getUrlAsString()); validateBean(p); }
@SuppressWarnings("unchecked") @Test public void build3() throws IntrospectionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { HttpProbe<String> p = new HttpProbe<String>() { @Override protected Map<String, Number> parseStream(InputStream stream) { return null; } }; p.setHost(webserver); ProbeDesc<String> pd = new ProbeDesc<String>(); pd.setProbeClass((Class<? extends Probe<String, ?>>) p.getClass()); p.setPd(pd); p.setFile("/file"); p.setPort(81); Assert.assertTrue(p.configure()); Assert.assertEquals("http://" + HOST + ":81/file", p.getUrlAsString()); Assert.assertEquals("http://" + HOST + ":81/file", pd.getBean("url").get(p).toString()); validateBean(p); }
@Test public void testBean() throws IOException, InvocationTargetException, IllegalArgumentException, IllegalAccessException { RRDToolProbe p = new RRDToolProbe(); p.setHost(new HostStarter(new HostInfo("toto"))); ProbeDesc<String> pd = new ProbeDesc<String>(); pd.setProbeClass(p.getClass()); pd.setName("Rrdtool"); pd.setProbeName("rrdtool"); p.setPd(pd); p.setRrdfile(rrdfile); Assert.assertEquals("invalid rrdfile bean", p.getRrdfile(), pd.getBean("rrdfile").get(p)); Assert.assertEquals("invalid rrdfile bean template ", p.getRrdfile().toString(), Util.parseTemplate("${attr.rrdfile}", p)); }
@SuppressWarnings("unchecked") @Test public void build1() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { HttpProbe<String> p = new HttpProbe<String>() { @Override protected Map<String, Number> parseStream(InputStream stream) { return null; } }; ProbeDesc<String> pd = new ProbeDesc<>(); pd.setProbeClass((Class<? extends Probe<String, ?>>) p.getClass()); p.setHost(webserver); p.setPd(pd); p.setFile("/"); p.setPort(80); Assert.assertTrue(p.configure()); Assert.assertEquals("http://" + HOST + ":80/", p.getUrlAsString()); validateBean(p); }
@SuppressWarnings("unchecked") @Test public void build4() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { HttpProbe<String> p = new HttpProbe<String>() { @Override protected Map<String, Number> parseStream(InputStream stream) { return null; } }; ProbeDesc<String> pd = new ProbeDesc<String>(); pd.setProbeClass((Class<? extends Probe<String, ?>>) p.getClass()); p.setHost(webserver); p.setPd(pd); p.setFile("/"); p.setPort(80); p.setLogin("login@domain"); p.setPassword("password"); Assert.assertTrue(p.configure()); Assert.assertEquals("http://login%40domain:password@" + HOST + ":80/", p.getUrlAsString()); validateBean(p); }