use of info.ganglia.gmetric4j.gmetric.GMetric in project flink by apache.
the class GangliaReporter method getReporter.
@Override
public ScheduledReporter getReporter(MetricConfig config) {
try {
String host = config.getString(ARG_HOST, null);
int port = config.getInteger(ARG_PORT, -1);
if (host == null || host.length() == 0 || port < 1) {
throw new IllegalArgumentException("Invalid host/port configuration. Host: " + host + " Port: " + port);
}
String addressingMode = config.getString(ARG_MODE_ADDRESSING, "MULTICAST");
int ttl = config.getInteger(ARG_TTL, 1);
GMetric gMetric = new GMetric(host, port, GMetric.UDPAddressingMode.valueOf(addressingMode), ttl);
String prefix = config.getString(ARG_PREFIX, null);
String conversionRate = config.getString(ARG_CONVERSION_RATE, null);
String conversionDuration = config.getString(ARG_CONVERSION_DURATION, null);
int dMax = config.getInteger(ARG_DMAX, 0);
int tMax = config.getInteger(ARG_TMAX, 60);
com.codahale.metrics.ganglia.GangliaReporter.Builder builder = com.codahale.metrics.ganglia.GangliaReporter.forRegistry(registry);
if (prefix != null) {
builder.prefixedWith(prefix);
}
if (conversionRate != null) {
builder.convertRatesTo(TimeUnit.valueOf(conversionRate));
}
if (conversionDuration != null) {
builder.convertDurationsTo(TimeUnit.valueOf(conversionDuration));
}
builder.withDMax(dMax);
builder.withTMax(tMax);
log.info("Configured GangliaReporter with {host:{}, port:{}, dmax:{}, tmax:{}, ttl:{}, addressingMode:{}}", host, port, dMax, tMax, ttl, addressingMode);
return builder.build(gMetric);
} catch (IOException e) {
throw new RuntimeException("Error while instantiating GangliaReporter.", e);
}
}
use of info.ganglia.gmetric4j.gmetric.GMetric in project lucene-solr by apache.
the class SolrGangliaReporter method start.
//this is a separate method for unit tests
void start() {
if (!testing) {
String id = host + ":" + port + ":" + multicast;
ganglia = serviceRegistry.getOrCreate(id, () -> new GMetric(host, port, multicast ? GMetric.UDPAddressingMode.MULTICAST : GMetric.UDPAddressingMode.UNICAST, 1));
if (ganglia == null) {
return;
}
}
if (instancePrefix == null) {
instancePrefix = registryName;
} else {
instancePrefix = instancePrefix + "." + registryName;
}
GangliaReporter.Builder builder = GangliaReporter.forRegistry(metricManager.registry(registryName)).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).prefixedWith(instancePrefix);
MetricFilter filter;
if (!filters.isEmpty()) {
filter = new SolrMetricManager.PrefixFilter(filters);
} else {
filter = MetricFilter.ALL;
}
builder = builder.filter(filter);
reporter = builder.build(ganglia);
reporter.start(period, TimeUnit.SECONDS);
}
use of info.ganglia.gmetric4j.gmetric.GMetric in project jmxtrans by jmxtrans.
the class GangliaWriter method internalWrite.
/**
* Send query result values to Ganglia.
*/
@Override
public void internalWrite(Server server, Query query, ImmutableList<Result> results) throws Exception {
for (final Result result : results) {
for (final Map.Entry<String, Object> resultValue : result.getValues().entrySet()) {
final String name = KeyUtils.getKeyString(query, result, resultValue, getTypeNames());
Object transformedValue = valueTransformer.apply(resultValue.getValue());
GMetricType dataType = getType(resultValue.getValue());
log.debug("Sending Ganglia metric {}={} [type={}]", name, transformedValue, dataType);
try (GMetric metric = new GMetric(host, port, addressingMode, ttl, v31, null, spoofedHostName)) {
metric.announce(name, transformedValue.toString(), dataType, units, slope, tmax, dmax, groupName);
}
}
}
}
use of info.ganglia.gmetric4j.gmetric.GMetric in project ninja by ninjaframework.
the class NinjaGanglia method start.
@Start(order = 90)
public void start() {
if (ninjaProperties.getBooleanWithDefault("metrics.ganglia.enabled", false)) {
final String hostname = metricsService.getHostname();
final String address = ninjaProperties.getOrDie("metrics.ganglia.address");
final int port = ninjaProperties.getIntegerWithDefault("metrics.ganglia.port", 8649);
final String period = ninjaProperties.getWithDefault("metrics.ganglia.period", "60s");
final int delay = TimeUtil.parseDuration(period);
try {
GMetric ganglia = new GMetric(address, port, UDPAddressingMode.MULTICAST, 1);
reporter = GangliaReporter.forRegistry(metricsService.getMetricRegistry()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build(ganglia);
reporter.start(delay, TimeUnit.SECONDS);
log.info("Started Ganglia Metrics reporter for '{}', updating every {}", hostname, period);
} catch (IOException e) {
log.error("Failed to start Ganglia reporter!", e);
}
}
}
use of info.ganglia.gmetric4j.gmetric.GMetric in project camel by apache.
the class GangliaEndpoint method getPublisher.
public synchronized Publisher getPublisher() {
if (publisher == null) {
GMetric gmetric = configuration.createGMetric();
publisher = new GMetricPublisher(gmetric);
}
return publisher;
}
Aggregations