Java 类com.codahale.metrics.jvm.FileDescriptorRatioGauge 实例源码

项目:codahale-aggregated-metrics-cloudwatch-reporter    文件:CloudWatchReporter.java   
public CloudWatchReporter build() {

            if (withJvmMetrics) {
                metricRegistry.register("jvm.uptime", (Gauge<Long>) () -> ManagementFactory.getRuntimeMXBean().getUptime());
                metricRegistry.register("jvm.current_time", (Gauge<Long>) clock::getTime);
                metricRegistry.register("jvm.classes", new ClassLoadingGaugeSet());
                metricRegistry.register("jvm.fd_usage", new FileDescriptorRatioGauge());
                metricRegistry.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
                metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet());
                metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet());
                metricRegistry.register("jvm.thread-states", new ThreadStatesGaugeSet());
            }

            cwRateUnit = toStandardUnit(rateUnit);
            cwDurationUnit = toStandardUnit(durationUnit);

            return new CloudWatchReporter(this);
        }
项目:it-keeps    文件:MetricsFactory.java   
public static void enableJvm() {

        if (bEnableJvm)
            return;

        METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
        METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
        METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
        METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
        METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_BUFFERS,
                new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));

        final JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build();
        jmxReporter.start();

        bEnableJvm = true;
    }
项目:metadatamanagement    文件:MetricsConfiguration.java   
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
  metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
  metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
  metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
  metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
  metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS,
      new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));

  servletContext.setAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE, metricRegistry);

  FilterRegistration.Dynamic metricsFilter =
      servletContext.addFilter("webappMetricsFilter", new InstrumentedFilter());

  metricsFilter.addMappingForUrlPatterns(
      EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC), true,
      "/*");
  metricsFilter.setAsyncSupported(true);
}
项目:tajo    文件:TajoSystemMetrics.java   
public void start() {
  setMetricsReporter(metricsGroupName);

  final String jvmMetricsName = metricsGroupName + "-JVM";
  setMetricsReporter(jvmMetricsName);

  if(!inited) {
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "MEMORY"), new MemoryUsageGaugeSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "FILE"), new FileDescriptorRatioGauge());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "GC"), new GarbageCollectorMetricSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "THREAD"), new ThreadStatesGaugeSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "LOG"), new LogEventGaugeSet());
    jmxReporter = JmxReporter.forRegistry(metricRegistry).inDomain("Tajo")
            .createsObjectNamesWith(new TajoJMXObjectNameFactory()).build();
    jmxReporter.start();
  }
  inited = true;
}
项目:oneops    文件:OneOpsMetrics.java   
/**
 * Add metrics JVM gauges.
 */
private void addJvmMetrics() {
  if (getB("jvm.gcstats", false)) {
    ooMetricsRegistry.registerAll(new GarbageCollectorMetricSet());
  }
  if (getB("jvm.memory", false)) {
    ooMetricsRegistry.registerAll(new MemoryUsageGaugeSet());
  }
  if (getB("jvm.threadstate", false)) {
    ooMetricsRegistry.registerAll(new ThreadStatesGaugeSet());
  }
  if (getB("jvm.filedescriptor", false)) {
    ooMetricsRegistry.register("openfd.ratio", new FileDescriptorRatioGauge());
  }
}
项目:curiostack    文件:MonitoringModule.java   
private static void configureJvmMetrics(MetricRegistry registry) {
  MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
  registry.register("jvm.buffer-pool", new BufferPoolMetricSet(mBeanServer));
  registry.register("jvm.class-loading", new ClassLoadingGaugeSet());
  registry.register("jvm.file-descriptor-ratio", new FileDescriptorRatioGauge());
  registry.register("jvm.gc", new GarbageCollectorMetricSet());
  registry.register("jvm.memory", new MemoryUsageGaugeSet());
  registry.register("jvm.threads", new ThreadStatesGaugeSet());
}
项目:BCDS    文件:MetricsConfiguration.java   
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (propertyResolver.getProperty(PROP_JMX_ENABLED, Boolean.class, false)) {
        log.info("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
}
项目:ehcache3-samples    文件:MetricsConfiguration.java   
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JCACHE_STATISTICS, new JCacheGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (hikariDataSource != null) {
        log.debug("Monitoring the datasource");
        hikariDataSource.setMetricRegistry(metricRegistry);
    }
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }

    if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
        log.info("Initializing Metrics Log reporting");
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
            .outputTo(LoggerFactory.getLogger("metrics"))
            .convertRatesTo(TimeUnit.SECONDS)
            .convertDurationsTo(TimeUnit.MILLISECONDS)
            .build();
        reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
    }
}
项目:haven-platform    文件:MeterConfiguration.java   
@Override
public void configureReporters(MetricRegistry metricRegistry) {
    metricRegistry.addListener(metricsListener);

    metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet());
    metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet());
    metricRegistry.register("jvm.thread-states", new ThreadStatesGaugeSet());
    metricRegistry.register("jvm.fd.usage", new FileDescriptorRatioGauge());


    if(environment.acceptsProfiles(AmqpUtils.PROFILE)) {
        final String applicationId = AppInfo.getApplicationName();
        AmqpUtils.ExchangeFactory exchangeFactory = new AmqpUtils.ExchangeFactory();
        exchangeFactory.setExchangeName(exchange);
        AmqpReporter amqpReporter = AmqpReporter.forRegistry(metricRegistry)
          .connectionFactoryProvider(connectionFactoryProvider)
          .exchangeName(exchange)
          .routingKey(applicationId)
          .exchangeFactory(exchangeFactory)
          .build();
        amqpReporter.start(reportPeriod, TimeUnit.SECONDS);
        LOG.info("AmqpReporter enabled: applicationId: {} reportPeriod: {} seconds, exchange: {}",
                applicationId, reportPeriod, exchange);
    } else {
        //sample configuration for metrics reported
        // https://dropwizard.github.io/metrics/3.1.0/manual/core/#man-core-reporters-console
        final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
                .outputTo(LoggerFactory.getLogger("com.codeabovelab.dm.metrics"))
                .convertRatesTo(TimeUnit.SECONDS)
                .convertDurationsTo(TimeUnit.MILLISECONDS)
                .build();
        reporter.start(reportPeriod, TimeUnit.SECONDS);
    }
}
项目:drill    文件:DrillMetrics.java   
private static void registerSystemMetrics() {
  REGISTRY.registerAll(new GarbageCollectorMetricSet());
  REGISTRY.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  REGISTRY.registerAll(new MemoryUsageGaugeSet());
  REGISTRY.registerAll(new ThreadStatesGaugeSet());
  register("fd.usage", new FileDescriptorRatioGauge());
}
项目:nexus-public    文件:MetricsServlet.java   
@Inject
public MetricsServlet(final MetricRegistry registry) {
  super(registry);

  // JVM metrics are no longer automatically added in codahale-metrics
  registry.register(name("jvm", "vm"), new JvmAttributeGaugeSet());
  registry.register(name("jvm", "memory"), new MemoryUsageGaugeSet());
  registry.register(name("jvm", "buffers"), new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  registry.register(name("jvm", "fd_usage"), new FileDescriptorRatioGauge());
  registry.register(name("jvm", "thread-states"), new ThreadStatesGaugeSet());
  registry.register(name("jvm", "garbage-collectors"), new GarbageCollectorMetricSet());
}
项目:lobbycal    文件:MetricsConfiguration.java   
@PostConstruct
public void init() {
    log.debug("Registering JVM gauges");
    metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
        log.debug("Initializing Metrics JMX reporting");
        JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
        jmxReporter.start();
    }
}
项目:datacollector    文件:MetricsModule.java   
@Provides @Singleton MetricRegistry provideMetrics() {
  MetricRegistry metrics = new MetricRegistry();
  metrics.register("jvm.memory", new MemoryUsageGaugeSet());
  metrics.register("jvm.garbage", new GarbageCollectorMetricSet());
  metrics.register("jvm.threads", new ThreadStatesGaugeSet());
  metrics.register("jvm.files", new FileDescriptorRatioGauge());
  metrics.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  return metrics;
}
项目:p2p-webtv    文件:MetricsConfiguration.java   
@PostConstruct
public void init() {
  log.debug("Registering JVM gauges");
  metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
  metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
  metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
  metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
  metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  if (applicationProperties.getMetrics().getJmx().isEnabled()) {
    log.debug("Initializing Metrics JMX reporting");
    JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
    jmxReporter.start();
  }
}
项目:agate    文件:MetricsConfiguration.java   
@PostConstruct
public void init() {
  log.debug("Registering JVM gauges");
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
  METRIC_REGISTRY
      .register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  if(propertyResolver.getProperty(PROP_JMX_ENABLED, Boolean.class, false)) {
    log.info("Initializing Metrics JMX reporting");
    JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build();
    jmxReporter.start();
  }
}
项目:modules    文件:MetricRegistryInitializer.java   
/**
 * Registers a default set of metrics for the JVM.
 */
private void registerDefaultMetrics() {
    metricRegistry.register(JVM_GARBAGE_COLLECTOR_METRICS, new GarbageCollectorMetricSet());
    metricRegistry.register(JVM_MEMORY_METRICS, new MemoryUsageGaugeSet());
    metricRegistry.register(JVM_THREAD_METRICS, new ThreadStatesGaugeSet());
    metricRegistry.register(JVM_FILE_DESCRIPTOR_METRICS, new FileDescriptorRatioGauge());
}
项目:incubator-tajo    文件:TajoSystemMetrics.java   
public void start() {
  setMetricsReporter(metricsGroupName);

  String jvmMetricsName = metricsGroupName + "-jvm";
  setMetricsReporter(jvmMetricsName);

  if(!inited) {
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "Heap"), new MemoryUsageGaugeSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "File"), new FileDescriptorRatioGauge());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "GC"), new GarbageCollectorMetricSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "Thread"), new ThreadStatesGaugeSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "Log"), new LogEventGaugeSet());
  }
  inited = true;
}
项目:tajo-cdh    文件:TajoSystemMetrics.java   
public void start() {
  setMetricsReporter(metricsGroupName);

  String jvmMetricsName = metricsGroupName + "-jvm";
  setMetricsReporter(jvmMetricsName);

  if(!inited) {
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "Heap"), new MemoryUsageGaugeSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "File"), new FileDescriptorRatioGauge());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "GC"), new GarbageCollectorMetricSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "Thread"), new ThreadStatesGaugeSet());
    metricRegistry.register(MetricRegistry.name(jvmMetricsName, "Log"), new LogEventGaugeSet());
  }
  inited = true;
}
项目:incubator-gobblin    文件:JMXReportingService.java   
private void registerJvmMetrics() {
  registerMetricSetWithPrefix("jvm.gc", new GarbageCollectorMetricSet());
  registerMetricSetWithPrefix("jvm.memory", new MemoryUsageGaugeSet());
  registerMetricSetWithPrefix("jvm.threads", new ThreadStatesGaugeSet());
  this.metricRegistry.register("jvm.fileDescriptorRatio", new FileDescriptorRatioGauge());
  for (Map.Entry<String, MetricSet> metricSet : this.additionalMetricSets.entrySet()) {
    registerMetricSetWithPrefix(metricSet.getKey(), metricSet.getValue());
  }
}
项目:chassis    文件:MetricsConfiguration.java   
/***
    * Initializes the metrics registry
    *
    * @return metric registry bean
    */
@Bean
public MetricRegistry metricRegistry() {
    final MetricRegistry bean = new MetricRegistry();

       // add JVM metrics
    bean.register("jvm.gc", new GarbageCollectorMetricSet());
    bean.register("jvm.memory", new MemoryUsageGaugeSet());
    bean.register("jvm.thread-states", new ThreadStatesGaugeSet());
    bean.register("jvm.fd", new FileDescriptorRatioGauge());

    return bean;
}
项目:chassis    文件:ChassisConfiguration.java   
/**
 * Initializes the metrics registry
 *
 * @return metric registry bean
 */
@Bean
public MetricRegistry metricRegistry() {
    final MetricRegistry bean = new MetricRegistry();

    // add JVM metrics
    bean.register("jvm.gc", new GarbageCollectorMetricSet());
    bean.register("jvm.memory", new MemoryUsageGaugeSet());
    bean.register("jvm.thread-states", new ThreadStatesGaugeSet());
    bean.register("jvm.fd", new FileDescriptorRatioGauge());
    bean.register("jvm.load-average", new Gauge<Double>() {
        private OperatingSystemMXBean mxBean = ManagementFactory.getOperatingSystemMXBean();

        public Double getValue() {
            try {
                return mxBean.getSystemLoadAverage();
            } catch (Exception e) {
                // not supported
                return -1d;
            }
        }
    });

    // add Logback metrics
    final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory();
    final Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME);
    final InstrumentedAppender appender = new InstrumentedAppender(bean);
    appender.setContext(root.getLoggerContext());
    appender.start();
    root.addAppender(appender);

    return bean;
}
项目:MLDS    文件:MetricsConfiguration.java   
@PostConstruct
public void init() {
    logger.debug("Registring JVM gauges");
    METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
    METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
    METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
    METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
    METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    if (propertyResolver.getProperty(PROP_JMX_ENABLED, Boolean.class, false)) {
        logger.info("Initializing Metrics JMX reporting");
        final JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build();
        jmxReporter.start();
    }
}
项目:mica2    文件:MetricsConfiguration.java   
@PostConstruct
public void init() {
  log.debug("Registering JVM gauges");
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
  METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
  METRIC_REGISTRY
      .register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  if(propertyResolver.getProperty(PROP_JMX_ENABLED, Boolean.class, false)) {
    log.info("Initializing Metrics JMX reporting");
    JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build();
    jmxReporter.start();
  }
}
项目:Decision    文件:SiddhiStreamReporterTest.java   
@Test
public void testReport() throws Exception {
    Clock clock= Clock.defaultClock();

    reporter= builder.convertRatesTo(TimeUnit.MINUTES)
            .convertDurationsTo(TimeUnit.SECONDS)
            .withClock(clock)
            .filter(MetricFilter.ALL)
            .build();

    reporter.start(1, TimeUnit.SECONDS);

    SortedMap<String, Gauge> gauges= new TreeMap<>();
    SortedMap<String, Counter> counters= new TreeMap<>();
    SortedMap<String, Histogram> histograms= new TreeMap<>();
    SortedMap<String, Meter> meters= new TreeMap<>();
    SortedMap<String, Timer> timers= new TreeMap<>();

    Gauge gauge= new FileDescriptorRatioGauge();
    gauges.put("gauges", gauge);

    Counter counter= new Counter();
    counters.put("counters", counter);

    Meter meter= new Meter();
    meters.put("meters", meter);

    Timer timer= new Timer();
    timers.put("timers", timer);

    Exception ex= null;
    try {
        reporter.report(gauges, counters, histograms, meters, timers);
    } catch (Exception e)   {ex= e; }
    assertNull("Expected null value that means not exception", ex);

}
项目:sling-metrics    文件:JvmMetrics.java   
@Activate
protected void activate(final ComponentContext context) {
    isEnabled = (Boolean) context.getProperties().get(JVM_METRICS_ENABLED);
    if(metricService.isEnabled() && isEnabled) {
        metricService.register(GARBAGE_COLLECTION_METRIC_NAME, new GarbageCollectorMetricSet());
        metricService.register(MEMORY_METRIC_NAME, new MemoryUsageGaugeSet());
        metricService.register(THREAD_STATES_METRIC_NAME, new ThreadStatesGaugeSet());
        metricService.register(FILE_DESCRIPTORS_USAGE_METRIC_NAME, new FileDescriptorRatioGauge());
    }
}
项目:haogrgr-test    文件:MetricsMain.java   
public static void main(String args[]) {
    startReport();
    Meter requests = metrics.meter("requests");
    metrics.register("jvm.gc", new GarbageCollectorMetricSet());
    metrics.register("jvm.fd", new FileDescriptorRatioGauge());
    metrics.register("jvm.mm", new MemoryUsageGaugeSet());
    metrics.register("jvm.tt", new ThreadStatesGaugeSet());
    for (int i = 0; i < 1000; i++) {
        requests.mark();
        waitRandSeconds();
    }
}
项目:stdlib    文件:CoreMetricsModule.java   
public static MetricRegistry buildRegistry()
{
    MetricRegistry registry = new MetricRegistry();

    registry.register(MetricRegistry.name("jvm", "gc"), new GarbageCollectorMetricSet());
    registry.register(MetricRegistry.name("jvm", "memory"), new MemoryUsageGaugeSet());
    registry.register(MetricRegistry.name("jvm", "thread-states"), new ThreadStatesGaugeSet());
    registry.register(MetricRegistry.name("jvm", "fd", "usage"), new FileDescriptorRatioGauge());

    return registry;
}
项目:cdk    文件:RegisterJVMMetricsBuilder.java   
public RegisterJVMMetrics(CommandBuilder builder, Config config, Command parent, 
                                   Command child, final MorphlineContext context) {

  super(builder, config, parent, child, context);      
  validateArguments();

  MetricRegistry registry = context.getMetricRegistry();
  BufferPoolMetricSet bufferPoolMetrics = new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer());
  registerAll("jvm.buffers", bufferPoolMetrics, registry);
  registerAll("jvm.gc", new GarbageCollectorMetricSet(), registry);
  registerAll("jvm.memory", new MemoryUsageGaugeSet(), registry);
  registerAll("jvm.threads", new ThreadStatesGaugeSet(), registry);
  register("jvm.fileDescriptorCountRatio", new FileDescriptorRatioGauge(), registry);
  context.getHealthCheckRegistry().register("deadlocks", new ThreadDeadlockHealthCheck());
}
项目:semantic-metrics    文件:FileDescriptorGaugeSet.java   
public FileDescriptorGaugeSet() {
    fileDescriptorRatioGauge = new FileDescriptorRatioGauge();
}
项目:Gobblin    文件:SchedulerDaemon.java   
private void registerJvmMetrics() {
  registerMetricSetWithPrefix("jvm.gc", new GarbageCollectorMetricSet());
  registerMetricSetWithPrefix("jvm.memory", new MemoryUsageGaugeSet());
  registerMetricSetWithPrefix("jvm.threads", new ThreadStatesGaugeSet());
  this.metricRegistry.register("jvm.fileDescriptorRatio", new FileDescriptorRatioGauge());
}
项目:Gobblin    文件:GobblinApplicationMaster.java   
private void registerJvmMetrics() {
  registerMetricSetWithPrefix("jvm.gc", new GarbageCollectorMetricSet());
  registerMetricSetWithPrefix("jvm.memory", new MemoryUsageGaugeSet());
  registerMetricSetWithPrefix("jvm.threads", new ThreadStatesGaugeSet());
  this.metricContext.register("jvm.fileDescriptorRatio", new FileDescriptorRatioGauge());
}
项目:Gobblin    文件:GobblinWorkUnitRunner.java   
private void registerJvmMetrics() {
  registerMetricSetWithPrefix("jvm.gc", new GarbageCollectorMetricSet());
  registerMetricSetWithPrefix("jvm.memory", new MemoryUsageGaugeSet());
  registerMetricSetWithPrefix("jvm.threads", new ThreadStatesGaugeSet());
  this.metricContext.register("jvm.fileDescriptorRatio", new FileDescriptorRatioGauge());
}
项目:SPQR    文件:SPQRNodeServer.java   
/**
 * @see io.dropwizard.Application#run(io.dropwizard.Configuration, io.dropwizard.setup.Environment)
 */
public void run(SPQRNodeServerConfiguration configuration, Environment environment) throws Exception {

    // initialize log4j environment using the settings provided via node configuration 
    initializeLog4j(configuration.getSpqrNode().getLog4jConfiguration());

    // check which type of resource management is requested via configuration 
    if(configuration.getResourceManagerConfiguration().getMode() == ResourceManagerMode.REMOTE) {

        // prepare for use remote resource management: fetch configuration  
        SPQRResourceManagerConfiguration resManCfg = configuration.getResourceManagerConfiguration();
        logger.info("[resource manager [mode="+ResourceManagerMode.REMOTE+", protocol="+resManCfg.getProtocol()+", host="+resManCfg.getHost()+", port="+resManCfg.getPort()+"]");

        // initialize client to use for remote communication
        this.resourceManagerClient = new SPQRResourceManagerClient(resManCfg.getProtocol(), resManCfg.getHost(), resManCfg.getPort(), new JerseyClientBuilder(environment).using(configuration.getHttpClient()).build("resourceManagerClient"));

        // finally: register node with remote resource manager
        this.nodeId = registerProcessingNode(configuration.getSpqrNode().getProtocol(), configuration.getSpqrNode().getHost(), configuration.getSpqrNode().getServicePort(), 
                configuration.getSpqrNode().getAdminPort(), this.resourceManagerClient);
        logger.info("node successfully registered [id="+nodeId+", proto="+configuration.getSpqrNode().getProtocol()+", host="+configuration.getSpqrNode().getHost()+", servicePort="+configuration.getSpqrNode().getServicePort()+", adminPort="+configuration.getSpqrNode().getAdminPort()+"]");

    } else {
        this.nodeId = "standalone";
        this.resourceManagerClient = null;
        logger.info("resource manager [mode="+ResourceManagerMode.LOCAL+"]");
    }

    // initialize the micro pipeline manager
    this.microPipelineManager = new MicroPipelineManager(this.nodeId, loadAndDeployApplicationRepository(configuration.getSpqrNode().getComponentRepositoryFolder()), configuration.getSpqrNode().getNumOfThreads());
    logger.info("pipeline manager initialized [threads="+configuration.getSpqrNode().getNumOfThreads()+", repo="+configuration.getSpqrNode().getComponentRepositoryFolder()+"]");

    // register exposed resources
    environment.jersey().register(new MicroPipelineResource(this.microPipelineManager));

    // register shutdown handler
    Runtime.getRuntime().addShutdownHook(new SPQRNodeShutdownHandler(this.microPipelineManager, this.resourceManagerClient, nodeId));

    // register metrics handler
    MetricsHandler handler = new MetricsHandler();
    if(configuration.getSpqrNode().getSpqrMetrics() != null) {
        final SPQRNodeMetricsConfiguration metricsCfg = configuration.getSpqrNode().getSpqrMetrics();

        if(metricsCfg.getMetricsReporter() != null && !metricsCfg.getMetricsReporter().isEmpty()) {

            if(metricsCfg.isAttachClassLoadingMetricCollector()) {
                handler.register(new ClassLoadingGaugeSet());
            }
            if(metricsCfg.isAttachFileDescriptorMetricCollector()) {
                handler.register("fs", new FileDescriptorRatioGauge());     
            }
            if(metricsCfg.isAttachGCMetricCollector()) {
                handler.register(new GarbageCollectorMetricSet());      
            }
            if(metricsCfg.isAttachMemoryUsageMetricCollector()) {
                handler.register(new MemoryUsageGaugeSet());        
            }
            if(metricsCfg.isAttachThreadStateMetricCollector()) {
                handler.register(new ThreadStatesGaugeSet());       
            }

            MetricsReporterFactory.attachReporters(handler, metricsCfg.getMetricsReporter());

            logger.info("metrics[classloader="+metricsCfg.isAttachClassLoadingMetricCollector()+
                               ",fileSystem="+metricsCfg.isAttachFileDescriptorMetricCollector()+
                               ",gc="+metricsCfg.isAttachGCMetricCollector()+
                               ",memory="+metricsCfg.isAttachMemoryUsageMetricCollector()+
                               ",threadState="+metricsCfg.isAttachThreadStateMetricCollector()+"]");

            StringBuffer buf = new StringBuffer();
            for(final MicroPipelineMetricsReporterConfiguration mr : metricsCfg.getMetricsReporter()) {
                buf.append("(id=").append(mr.getId()).append(", type=").append(mr.getType()).append(")");
            }
            logger.info("metricReporters["+buf.toString()+"]");
        }
    } else {
        logger.info("no metrics and metric reporters configured for processing node '"+nodeId+"'");
    }
}
项目:werval    文件:MetricsPlugin.java   
private void registerMetrics( Application application, MetricRegistry metrics )
{
    Config config = application.config().atKey( "metrics" );

    // JVM Meters
    if( config.bool( "jvm.bufferpools.enabled" ) )
    {
        metrics.register( "jvm.bufferpools", new BufferPoolMetricSet( getPlatformMBeanServer() ) );
    }
    if( config.bool( "jvm.threadstates.enabled" ) )
    {
        metrics.register( "jvm.threadstates", new ThreadStatesGaugeSet() );
    }
    if( config.bool( "jvm.classloading.enabled" ) )
    {
        metrics.register( "jvm.classloading", new ClassLoadingGaugeSet() );
    }
    if( config.bool( "jvm.garbagecollection.enabled" ) )
    {
        metrics.register( "jvm.garbagecollection", new GarbageCollectorMetricSet() );
    }
    if( config.bool( "jvm.memory.enabled" ) )
    {
        metrics.register( "jvm.memory", new MemoryUsageGaugeSet() );
    }
    if( config.bool( "jvm.filedescriptors.enabled" ) )
    {
        metrics.register( "jvm.filedescriptors.ratio", new FileDescriptorRatioGauge() );
    }

    // Connection & HTTP Metrics
    requestTimers = new ConcurrentHashMap<>();
    eventRegistration = application.events().registerListener(
        new EventListener(
            metrics,
            requestTimers,
            config.bool( "http.connections.enabled" ),
            config.bool( "http.requests.enabled" ),
            config.bool( "http.success.enabled" ),
            config.bool( "http.redirections.enabled" ),
            config.bool( "http.client_errors.enabled" ),
            config.bool( "http.server_errors.enabled" ),
            config.bool( "http.unknown.enabled" )
        )
    );
}
项目:checklistbank    文件:RabbitBaseService.java   
/**
 * Binds metrics to an existing metrics registry.
 * override this method to add more service specific metrics
 */
protected void initMetrics(MetricRegistry registry) {
  registry.registerAll(new MemoryUsageGaugeSet());
  registry.register(Metrics.OPEN_FILES, new FileDescriptorRatioGauge());
}