Java 类com.codahale.metrics.ganglia.GangliaReporter 实例源码

项目:micrometer    文件:GangliaMeterRegistry.java   
public GangliaMeterRegistry(GangliaConfig config, Clock clock, HierarchicalNameMapper nameMapper, MetricRegistry metricRegistry) {
    // Technically, Ganglia doesn't have any constraints on metric or tag names, but the encoding of Unicode can look
    // horrible in the UI. So be aware...
    super(config, metricRegistry, nameMapper, clock);
    this.config = config;

    try {
        final GMetric ganglia = new GMetric(config.host(), config.port(), config.addressingMode(), config.ttl());
        this.reporter = GangliaReporter.forRegistry(getDropwizardRegistry())
                .convertRatesTo(config.rateUnits())
                .convertDurationsTo(config.durationUnits())
                .build(ganglia);

        if(config.enabled())
            start();
    } catch (IOException e) {
        throw new RuntimeException("Failed to configure Ganglia metrics reporting", e);
    }
}
项目:fathom    文件:Reporter.java   
@Override
public void start(Settings settings, MetricRegistry metricRegistry) {
    if (settings.getBoolean("metrics.ganglia.enabled", false)) {

        final String hostname = settings.getLocalHostname();
        final String address = settings.getRequiredString("metrics.ganglia.address");
        final int port = settings.getInteger("metrics.ganglia.port", 8649);
        final long period = settings.getDuration("metrics.ganglia.period", TimeUnit.SECONDS, 60);

        try {
            GMetric ganglia = new GMetric(address, port, UDPAddressingMode.MULTICAST, 1);
            reporter = GangliaReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS)
                    .convertDurationsTo(TimeUnit.MILLISECONDS).build(ganglia);
            reporter.start(period, TimeUnit.SECONDS);

            log.info("Started Ganglia Metrics reporter for '{}', updating every {} seconds", hostname, period);

        } catch (IOException e) {
            log.error("Failed to start Ganglia reporter!", e);
        }

    } else {
        log.debug("Ganglia Metrics reporter is disabled");
    }
}
项目:pippo    文件:Reporter.java   
@Override
public void start(PippoSettings settings, MetricRegistry metricRegistry) {
    if (settings.getBoolean("metrics.ganglia.enabled", false)) {

        final String hostname = settings.getLocalHostname();
        final String address = settings.getRequiredString("metrics.ganglia.address");
        final int port = settings.getInteger("metrics.ganglia.port", 8649);
        final long period = settings.getDurationInSeconds("metrics.ganglia.period", 60);

        try {
            GMetric ganglia = new GMetric(address, port, UDPAddressingMode.MULTICAST, 1);
            reporter = GangliaReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS)
                    .convertDurationsTo(TimeUnit.MILLISECONDS).build(ganglia);
            reporter.start(period, TimeUnit.SECONDS);

            log.info("Started Ganglia Metrics reporter for '{}', updating every {} seconds", hostname, period);

        } catch (IOException e) {
            log.error("Failed to start Ganglia reporter!", e);
        }

    } else {
        log.debug("Ganglia Metrics reporter is disabled");
    }
}
项目:checklistbank    文件:GangliaConfiguration.java   
/**
 * Starts the GangliaReporter, pointing to the configured host and port.
 */
@JsonIgnore
public void start(MetricRegistry registry) {
  if (host != null && port > 0) {
    try {
      final GMetric ganglia = new GMetric(host, port, GMetric.UDPAddressingMode.MULTICAST, 1);
      final GangliaReporter reporter = GangliaReporter.forRegistry(registry)
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS)
        .build(ganglia);
      reporter.start(1, TimeUnit.MINUTES);
      LOG.info("Reporting to ganglia at {}:{}", host, port);
    } catch (IOException e) {
      LOG.warn("Failed to setup ganglia reporting at {}:{}", host, port, e);
    }
  }
}
项目:Lagerta    文件:StatisticsCollector.java   
/** */
public void enableGangliaReporting(InetSocketAddress gangliaAddress) throws IOException {
    GMetric ganglia = new GMetric(gangliaAddress.getHostString(), gangliaAddress.getPort(),
        GMetric.UDPAddressingMode.UNICAST, 1);
    GangliaReporter reporter = GangliaReporter.forRegistry(registry)
        .prefixedWith(GANGLIA_METRICS_PREFIX)
        .build(ganglia);
    reporter.start(reportFrequency, TimeUnit.MILLISECONDS);
}
项目:Lagerta    文件:GangliaReporterProvider.java   
@Override public ScheduledReporter getIfEnabled() {
    if (!config.isGangliaReportingEnabled()) {
        return null;
    }
    try {
        InetSocketAddress gangliaAddress = config.getGangliaAddress();
        GMetric ganglia = new GMetric(gangliaAddress.getHostString(), gangliaAddress.getPort(),
            GMetric.UDPAddressingMode.UNICAST, 1);
        return GangliaReporter.forRegistry(registry)
            .prefixedWith(StatisticsCollector.GANGLIA_METRICS_PREFIX)
            .build(ganglia);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
项目:athena    文件:DefaultGangliaMetricsReporter.java   
/**
 * Builds reporter with the given ganglia metric.
 *
 * @param gMetric ganglia metric
 * @return reporter
 */
private GangliaReporter buildReporter(GMetric gMetric) {
    MetricRegistry mr = metricsService.getMetricRegistry();

    return GangliaReporter.forRegistry(filter(mr))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build(gMetric);
}
项目:graylog-plugin-metrics-reporter    文件:MetricsGangliaReporterModule.java   
@Override
protected void configure() {
    bind(GMetric.class).toProvider(GMetricProvider.class);
    bind(GangliaReporter.class).toProvider(GangliaReporterProvider.class);

    addConfigBeans();
    addInitializer(MetricsGangliaReporterService.class);
}
项目:graylog-plugin-metrics-reporter    文件:GangliaReporterProvider.java   
@Override
public GangliaReporter get() {
    return GangliaReporter.forRegistry(metricRegistry)
            .prefixedWith(configuration.getPrefix())
            .convertRatesTo(configuration.getUnitRates())
            .convertDurationsTo(configuration.getUnitDurations())
            .withDMax(configuration.getDMax())
            .withTMax(configuration.getTMax())
            .filter(new RegexMetricFilter(configuration.getIncludeMetrics()))
            .build(gMetric);
}
项目:graylog-plugin-metrics-reporter    文件:GangliaReporterProviderTest.java   
@Test
public void get() throws Exception {
    final MetricsGangliaReporterConfiguration configuration = new MetricsGangliaReporterConfiguration();
    final GMetric graphiteSender = new GMetric("127.0.0.1", 12345, null, 23);
    final MetricRegistry metricRegistry = new MetricRegistry();
    final GangliaReporterProvider provider = new GangliaReporterProvider(configuration, graphiteSender, metricRegistry);

    final GangliaReporter reporter = provider.get();
    assertNotNull(reporter);
}
项目:FinanceAnalytics    文件:MetricsRepositoryComponentFactory.java   
/**
 * Initialize publishing by Ganglia.
 * <p>
 * Only the summary registry is published.
 * 
 * @param repo  the component repository, not null
 * @param summaryRegistry  the summary metrics registry, not null
 * @param detailedRegistry  the detailed metrics registry, not null
 */
protected void initGangliaPublish(ComponentRepository repo, MetricRegistry summaryRegistry, MetricRegistry detailedRegistry) throws IOException {
  ArgumentChecker.notNull(getGangliaAddress(), "gangliaAddress");
  ArgumentChecker.notNull(getGangliaPort(), "gangliaPort");
  ArgumentChecker.notNull(getGangliaAddressingMode(), "gangliaAddressingMode");
  ArgumentChecker.notNull(getGangliaTtl(), "gangliaTtl");
  GMetric ganglia = new GMetric(getGangliaAddress(), getGangliaPort(), UDPAddressingMode.valueOf(getGangliaAddressingMode()), getGangliaTtl(), true);
  GangliaReporter gangliaReporter = GangliaReporter.forRegistry(summaryRegistry)
      .convertRatesTo(TimeUnit.SECONDS)
      .convertDurationsTo(TimeUnit.MILLISECONDS)
      .build(ganglia);
  repo.registerLifecycle(new GangliaReporterLifecycle(gangliaReporter));
}
项目:graylog-plugin-metrics    文件:MetricsOutput.java   
private GangliaReporter createGangliaReporter(URI uri) {
    GangliaReporter gangliaReporter = null;
    try {
        final GMetric ganglia = new GMetric(uri.getHost(), uri.getPort(), GMetric.UDPAddressingMode.MULTICAST, 1);
        gangliaReporter = GangliaReporter.forRegistry(registry)
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .prefixedWith(configuration.getString(CK_PREFIX))
                .build(ganglia);
        gangliaReporter.start(configuration.getInt(CK_RUN_RATE), TimeUnit.SECONDS);
    } catch (IOException e) {
        LOG.error("Can not connect to Ganglia server");
    }
    return gangliaReporter;
}
项目:onos    文件:DefaultGangliaMetricsReporter.java   
/**
 * Builds reporter with the given ganglia metric.
 *
 * @param gMetric ganglia metric
 * @return reporter
 */
private GangliaReporter buildReporter(GMetric gMetric) {
    MetricRegistry mr = metricsService.getMetricRegistry();

    return GangliaReporter.forRegistry(filter(mr))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build(gMetric);
}
项目:pravega    文件:StatsProviderImpl.java   
@Synchronized
@Override
public void start() {
    init();

    if (conf.isEnableCSVReporter()) {
        // NOTE:  metrics output files are exclusive to a given process
        File outdir;
        if (!Strings.isNullOrEmpty(conf.getMetricsPrefix())) {
            outdir = new File(conf.getCsvEndpoint(), conf.getMetricsPrefix());
        } else {
            outdir = new File(conf.getCsvEndpoint());
        }
        outdir.mkdirs();
        log.info("Configuring stats with csv output to directory [{}]", outdir.getAbsolutePath());
        reporters.add(CsvReporter.forRegistry(getMetrics())
                      .convertRatesTo(TimeUnit.SECONDS)
                      .convertDurationsTo(TimeUnit.MILLISECONDS)
                      .build(outdir));
    }
    if (conf.isEnableStatsdReporter()) {
        log.info("Configuring stats with statsD at {}:{}", conf.getStatsDHost(), conf.getStatsDPort());
        reporters.add(StatsDReporter.forRegistry(getMetrics())
                      .build(conf.getStatsDHost(), conf.getStatsDPort()));
    }
    if (conf.isEnableGraphiteReporter()) {
        log.info("Configuring stats with graphite at {}:{}", conf.getGraphiteHost(), conf.getGraphitePort());
        final Graphite graphite = new Graphite(new InetSocketAddress(conf.getGraphiteHost(), conf.getGraphitePort()));
        reporters.add(GraphiteReporter.forRegistry(getMetrics())
            .prefixedWith(conf.getMetricsPrefix())
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .filter(MetricFilter.ALL)
            .build(graphite));
    }
    if (conf.isEnableJMXReporter()) {
        log.info("Configuring stats with jmx {}", conf.getJmxDomain());
        final JmxReporter jmx = JmxReporter.forRegistry(getMetrics())
            .inDomain(conf.getJmxDomain())
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        jmx.start();
    }
    if (conf.isEnableGangliaReporter()) {
        try {
            log.info("Configuring stats with ganglia at {}:{}", conf.getGangliaHost(), conf.getGangliaPort());
            final GMetric ganglia = new GMetric(conf.getGangliaHost(), conf.getGangliaPort(), GMetric.UDPAddressingMode.MULTICAST, 1);
            reporters.add(GangliaReporter.forRegistry(getMetrics())
                .prefixedWith(conf.getMetricsPrefix())
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build(ganglia));
        } catch (IOException e) {
            log.warn("ganglia create failure: {}", e);
        }
    }
    if (conf.isEnableConsoleReporter()) {
        log.info("Configuring console reporter");
        reporters.add(ConsoleReporter.forRegistry(getMetrics())
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build());
    }
    for (ScheduledReporter r : reporters) {
        r.start(conf.getStatsOutputFrequencySeconds(), TimeUnit.SECONDS);
    }
}
项目:graylog-plugin-metrics-reporter    文件:MetricsGangliaReporterService.java   
@Inject
public MetricsGangliaReporterService(GangliaReporter gangliaReporter,
                                     MetricsGangliaReporterConfiguration configuration) {
    this.gangliaReporter = requireNonNull(gangliaReporter);
    this.configuration = requireNonNull(configuration);
}
项目:FinanceAnalytics    文件:MetricsRepositoryComponentFactory.java   
public GangliaReporterLifecycle(GangliaReporter gangliaReporter) {
  _gangliaReporter = gangliaReporter;
}