protected void flushStatus() { if (transactions > 0) { try { Sample sample = db.createSample(endInterval); if (transactionsEnabled) { sample.setValue("transactions!", transactions); } if (minEnabled) { sample.setValue("min", min); } if (maxEnabled) { sample.setValue("max", max); } if (averageEnabled) { double value = total / (double) transactions; sample.setValue("average", value); } sample.update(); } catch (IOException e) { throw new EtmException(e); } } }
private void updateSample(long now, double val) throws IOException { LOGGER.debug( "Sample time is [{}], updating metric [{}] with value [{}]", MetricsUtil.getCalendarTime(now), mbeanName, val); sample.setTime(now); sample.setValue(rrdDataSourceName, val); sample.update(); }
public void commit(JrdsSample sample) { RrdDb rrdDb = null; try { rrdDb = factory.getRrd(getPath()); Sample onesample = rrdDb.createSample(sample.getTime().getTime() / 1000); for(Map.Entry<String, Number> e: sample.entrySet()) { onesample.setValue(e.getKey(), e.getValue().doubleValue()); } if(p.getNamedLogger().isDebugEnabled()) log(Level.DEBUG, "%s", onesample.dump()); onesample.update(); } catch (IOException e) { log(Level.ERROR, e, "Error while collecting: %s", e.getMessage()); } finally { if(rrdDb != null) factory.releaseRrd(rrdDb); } }
sample.setValue("a", Math.sin(t / 3000.0) * 50 + 50); sample.update();