@Override protected void open() { super.open(); checkState(gmetrics == null, "open was already called"); log.info("opening ganglia output with hosts: {}", hostsToString()); gmetrics = hosts.stream().map(hostPort -> { try { return new GMetric(hostPort.getHost(), hostPort.getPort(), UNICAST, 1); } catch (IOException ex) { throw new UncheckedIOException(ex); } }).collect(Collectors.toList()); }
public List<HostPort> parseHostString() { // Done manually to avoid a guava dep List<HostPort> hosts = new ArrayList<HostPort>(); String[] hostPairs = getHostsString().split(","); for (int i = 0; i < hostPairs.length; i++) { String[] pair = hostPairs[i].split(":"); hosts.add(new HostPort(pair[0], Integer.valueOf(pair[1]))); } return hosts; }
@Override public boolean enable(final MetricRegistry registry) { boolean success = checkClass("com.izettle.metrics.influxdb.InfluxDbReporter"); if (!success) { return false; } List<HostPort> hosts = getFullHostList(); if (hosts == null || hosts.isEmpty()) { log.error("No hosts specified, cannot enable InfluxDBReporter"); return false; } if(hosts.size() != 1) { log.error("Only 1 host can be specified, cannot enable InfluxDBReporter"); return false; } HostPort hostPort = hosts.get(0); log.info("Enabling InfluxDBReporter to {}:{}", hostPort.getHost(), hostPort.getPort()); try { enableMetrics3(hostPort, registry); } catch (Exception e) { log.error("Failed to enable InfluxDBReporter for {}:{}", hostPort.getHost(), hostPort.getPort(), e); return false; } return true; }
public List<HostPort> parseHostString() { // Done manually to avoid a guava dep List<HostPort> hosts = new ArrayList<HostPort>(); String[] hostPairs = getHostsString().split(","); for (int i = 0; i < hostPairs.length; i++) { String[] pair = hostPairs[i].split(":"); hosts.add(new HostPort(pair[0], Integer.valueOf(pair[1]))); } return hosts; }
@Override public boolean enable(MetricRegistry registry) { boolean success = setup("com.codahale.metrics.ganglia.GangliaReporter"); if (!success) { return false; } List<HostPort> hosts = getFullHostList(); for (HostPort hostPort : hosts) { log.info("Enabling GangliaReporter to {}:{}", new Object[]{hostPort.getHost(), hostPort.getPort()}); try { enableMetrics3(hostPort, registry); } catch (Exception e) { log.error("Faliure while enabling GangliaReporter", e); return false; } } return true; }
protected HostPort makeHostPort(Map<String,String> chan) { if (chan.containsKey("mcast_join") || chan.containsKey("mcast_if")) { log.warn("Looks like a multicast send channel, not supported and ignoring: {}", chan); return null; } HostPort hp = null; try { hp = new HostPort(chan.get("host"), (Integer.valueOf(chan.get("port")))); } catch (Exception e) { // beter with slf4j 1.7 log.warn("Failed to create HostPort for:" + chan, e); } return hp; }
@Override public boolean enable(MetricRegistry registry) { boolean success = setup("com.codahale.metrics.graphite.GraphiteReporter"); if (!success) { return false; } List<HostPort> hosts = getFullHostList(); for (HostPort hostPort : hosts) { log.info("Enabling GraphiteReporter to {}:{}", new Object[]{hostPort.getHost(), hostPort.getPort()}); try { enableMetrics3(hostPort, registry); } catch (Exception e) { log.error("Failed to enable GraphiteReporter", e); return false; } } return true; }
public HostPort makeHostPort(Map<String,String> chan) { if (chan.containsKey("mcast_join") || chan.containsKey("mcast_if")) { log.warn("Looks like a multicast send channel, not supported and ignoring: {}", chan); return null; } HostPort hp = null; try { hp = new HostPort(chan.get("host"), Integer.valueOf(chan.get("port"))); } catch (Exception e) { // beter with slf4j 1.7 log.warn("Failed to create HostPort for:" + chan, e); } return hp; }
@Override public boolean enable() { boolean success = setup("com.yammer.metrics.reporting.GangliaReporter"); if (!success) { return false; } List<HostPort> hosts = getFullHostList(); for (HostPort hostPort : hosts) { log.info("Enabling GangliaReporter to {}:{}", new Object[]{hostPort.getHost(), hostPort.getPort()}); try { enableMetrics2(hostPort); } catch (Exception e) { log.error("Faliure while enabling GangliaReporter", e); return false; } } return true; }
@Test public void validationWorks() throws IOException { assertFalse(ReporterConfig.validate(new HostPort())); }
@Override public boolean enable() { boolean success = setup("com.yammer.metrics.reporting.GraphiteReporter"); if (!success) { return false; } List<HostPort> hosts = getFullHostList(); for (HostPort hostPort : hosts) { log.info("Enabling GraphiteReporter to {}:{}", new Object[]{hostPort.getHost(), hostPort.getPort()}); try { enableMetrics2(hostPort); } catch (Exception e) { log.error("Failed to enable GraphiteReporter", e); return false; } } return true; } }
@Test public void validationWorks() throws IOException { assertFalse(ReporterConfig.validate(new HostPort())); }
new Object[] {hostPort.getHost(), hostPort.getPort()}); StatsDReporter reporter = new StatsDReporter( Metrics.defaultRegistry(), MetricPredicateTransformer.generatePredicate(getPredicate()), Clock.defaultClock(), new StatsDConstructorHack(hostPort.getHost(), hostPort.getPort())); reporter.start(getPeriod(), getRealTimeunit()); reporters.add(reporter); new Object[] {hostPort.getHost(), hostPort.getPort()}, e); failures = true;
log.info("Enabling GangliaReporter to {}:{}", new Object[] {hostPort.getHost(), hostPort.getPort()}); try MetricPredicate.class, Boolean.TYPE); enable.invoke(null, Metrics.defaultRegistry(), getPeriod(), getRealTimeunit(), hostPort.getHost(), hostPort.getPort(), resolvePrefix(groupPrefix), getResolvedPrefix(), getMetricPredicate(), compressPackageNames); MetricPredicate.class, Boolean.TYPE); enable.invoke(null, Metrics.defaultRegistry(), getPeriod(), getRealTimeunit(), hostPort.getHost(), hostPort.getPort(), resolvePrefix(groupPrefix), getMetricPredicate(), compressPackageNames);
@Override public boolean enable(MetricRegistry registry) { if (!isClassAvailable(SENDER_CLASS)) { log.error("Tried to enable Zabbix Reporter, but class {} was not found", SENDER_CLASS); return false; } this.registry = registry; if (hostName == null) hostName = System.getenv("COMPUTERNAME"); if (hostName == null) hostName = System.getenv("HOSTNAME"); if (hostName == null) hostName = "localhost"; // note: don't go via InetAddress.getLocalHost() as that may return unexpected results or // take a long time (DNS roundtrips/timeouts) or even an exception being throws, for (HostPort hostPort : getFullHostList()) { ZabbixSender sender = new ZabbixSender(hostPort.getHost(), hostPort.getPort(), connectTimeout, socketTimeout); MetricFilter filter = MetricFilterTransformer.generateFilter(getPredicate()); ZabbixReporter reporter = new ZabbixReporter(sender, hostName, prefix, registry, name, filter, getRealRateunit(), getRealDurationunit()); reporters.add(reporter); } return true; }
new Object[] {hostPort.getHost(), hostPort.getPort()}); StatsDReporter reporter = StatsDReporter.forRegistry(registry) .convertRatesTo(getRealRateunit()) .prefixedWith(getResolvedPrefix()) .filter(MetricFilterTransformer.generateFilter(getPredicate())) .build(hostPort.getHost(), hostPort.getPort()); reporter.start(getPeriod(), getRealTimeunit()); reporters.add(reporter); new Object[] {hostPort.getHost(), hostPort.getPort()}, e); failures = true;
@Test public void endToEnd() throws Exception { GmondConfigParser g = new GmondConfigParser(); List<HostPort> hosts = g. getGmondSendChannels("src/test/resources/gmond/comments.conf"); //System.out.println(hosts); assertEquals(2, hosts.size()); assertEquals("foo1.local", hosts.get(0).getHost()); assertEquals(8649, hosts.get(0).getPort()); assertEquals("foo2.local", hosts.get(1).getHost()); assertEquals(8649, hosts.get(1).getPort()); }
@Test public void endToEnd() throws Exception { GmondConfigParser g = new GmondConfigParser(); List<HostPort> hosts = g. getGmondSendChannels("src/test/resources/gmond/comments.conf"); //System.out.println(hosts); assertEquals(2, hosts.size()); assertEquals("foo1.local", hosts.get(0).getHost()); assertEquals(8649, hosts.get(0).getPort()); assertEquals("foo2.local", hosts.get(1).getHost()); assertEquals(8649, hosts.get(1).getPort()); }