/** * Sets the time when the graph should begin. Time in seconds since epoch * (1970-01-01) is required. Negative numbers are relative to the current time. * * @param time Starting time for the graph in seconds since epoch */ public void setStartTime(long time) { this.startTime = time; if (time <= 0) { this.startTime += Util.getTime(); } }
/** * Just an alias for {@link #getTime()} method. * * @return Current timestamp (without milliseconds) */ public static long getTimestamp() { return getTime(); }
/** * Sets the time when the graph should end. Time in seconds since epoch * (1970-01-01) is required. Negative numbers are relative to the current time. * * @param time Ending time for the graph in seconds since epoch */ public void setEndTime(long time) { this.endTime = time; if (time <= 0) { this.endTime += Util.getTime(); } }
@Override void do_method(RpnCalculator c, State s) { c.push(Util.getTime()); } },
/** * Sets the time when the graph should end. Time in seconds since epoch * (1970-01-01) is required. Negative numbers are relative to the current time. * * @param time Ending time for the graph in seconds since epoch */ public void setEndTime(long time) { this.endTime = time; if (time <= 0) { this.endTime += Util.getTime(); } }
/** * Just an alias for {@link #getTime()} method. * * @return Current timestamp (without milliseconds) */ public static long getTimestamp() { return getTime(); }
/** * Sets the time when the graph should begin. Time in seconds since epoch * (1970-01-01) is required. Negative numbers are relative to the current time. * * @param time Starting time for the graph in seconds since epoch */ public void setStartTime(long time) { this.startTime = time; if (time <= 0) { this.startTime += Util.getTime(); } }
public static void main(String[] args) { System.out.println("RRD4J :: RRDTool choice for the Java world"); System.out.println("==============================================================================="); System.out.println("RRD4J base directory: " + Util.getRrd4jHomeDirectory()); long time = Util.getTime(); System.out.println("Current time: " + time + ": " + new Date(time * 1000L)); System.out.println("-------------------------------------------------------------------------------"); System.out.println("See https://rrd4j.dev.java.net for more information and the latest version."); System.out.println("Copyright 2010 Sasa Markovic and Mathias Bogaert. Licensed under the Apache License, Version 2.0."); }
/** * <p>Creates new sample with the current timestamp and all data source values set to * 'unknown'. Use returned <code>Sample</code> object to specify * datasource values for the current timestamp. See documentation for * {@link Sample Sample} for an explanation how to do this.</p> * <p>Once populated with data source values, call Sample's * {@link org.rrd4j.core.Sample#update() update()} method to actually * store sample in the RRD associated with it.</p> * * @return Fresh sample with the current timestamp and all data source values set to 'unknown'. * @throws java.io.IOException Thrown in case of I/O error. */ public Sample createSample() throws IOException { return createSample(Util.getTime()); }
private void showTimestamp() { long timestamp = Util.getTime(); setTitle(timestamp + " seconds since epoch"); }
/** * main. * * @param args an array of {@link java.lang.String} objects. */ public static void main(String[] args) { System.out.println("RRD4J :: RRDTool choice for the Java world"); System.out.println("==============================================================================="); System.out.println("RRD4J base directory: " + Util.getRrd4jHomeDirectory()); long time = Util.getTime(); System.out.println("Current time: " + time + ": " + new Date(time * 1000L)); System.out.println("-------------------------------------------------------------------------------"); System.out.println("See https://github.com/rrd4j/rrd4j for more information and the latest version."); System.out.println("Copyright 2017 The RRD4J Authors. Copyright (c) 2001-2005 Sasa Markovic and Ciaran Treanor. Copyright (c) 2013 The OpenNMS Group, Inc.. Licensed under the Apache License, Version 2.0."); }
/** * <p>Creates new sample with the current timestamp and all data source values set to * 'unknown'. Use returned <code>Sample</code> object to specify * datasource values for the current timestamp. See documentation for * {@link Sample Sample} for an explanation how to do this.</p> * <p/> * <p>Once populated with data source values, call Sample's * {@link Sample#update() update()} method to actually * store sample in the RRD associated with it.</p> * * @return Fresh sample with the current timestamp and all * data source values set to 'unknown'. * @throws IOException Thrown in case of I/O error. */ public Sample createSample() throws IOException { return createSample(Util.getTime()); }
time = Util.getTime();
time = Util.getTime();
/** * Performs update of the rrd with the current value of the gauge * @throws IOException */ public void update() throws IOException { logger.debug("RRDRequestExecutionTimeGauge.update() rrdFileName is {}", rrdFileName); RrdDb rrdDb = new RrdDb(rrdFileName); try { Sample sample = rrdDb.createSample(); long currentTimeSecs = Util.getTime(); String update = Long.toString(currentTimeSecs) +':'+ (long) gauge.resetAndGetAverageExecutionTime()+':'; sample.setAndUpdate(update); logger.debug("RRDRequestExecutionTimeGauge.update() updated with : {}", update); } finally { rrdDb.close(); logger.debug("RRDRequestExecutionTimeGauge.update() succeeded"); } }
/** * * @throws IOException */ public void update() throws IOException { logger.debug("RRDRequestCounter.update() rrdFileName is {}", rrdFileName); RrdDb rrdDb = new RrdDb(rrdFileName); Sample sample = rrdDb.createSample(); long currentTimeSecs = Util.getTime(); StringBuilder sb = new StringBuilder(); sb.append(currentTimeSecs).append(':'); sb.append(counter.getTotalRequests()).append(':'); sb.append(counter.getFailed()); sample.setAndUpdate(sb.toString()); logger.debug("RRDRequestCounter.update() updated with : {}", sb); rrdDb.close(); logger.debug("RRDRequestCounter.update() succeeded"); logger.debug("RRDRequestCounter.update() let us try to fetch data"); rrdDb = new RrdDb(rrdFileName); if(dumpstart == null) { dumpstart = currentTimeSecs - 100; } FetchRequest fetchRequest = rrdDb.createFetchRequest(ConsolFun.AVERAGE, dumpstart, currentTimeSecs+1); FetchData fetchData = fetchRequest.fetchData(); logger.debug("RRDRequestCounter.update() dump is: {}", fetchData.dump()); rrdDb.close(); }
private void fetchRrdData() throws IOException { long tEndFixed = (tEnd == 0) ? Util.getTime() : tEnd; for (int i = 0; i < defSources.length; i++) { if (!defSources[i].isLoaded()) { // not fetched yet Set<String> dsNames = new HashSet<String>(); dsNames.add(defSources[i].getDsName()); // look for all other datasources with the same path and the same consolidation function for (int j = i + 1; j < defSources.length; j++) { if (defSources[i].isCompatibleWith(defSources[j])) { dsNames.add(defSources[j].getDsName()); } } // now we have everything try (RrdDb rrd = getRrd(defSources[i])){ lastRrdArchiveUpdateTime = Math.max(lastRrdArchiveUpdateTime, rrd.getLastArchiveUpdateTime()); FetchRequest req = rrd.createFetchRequest(defSources[i].getConsolFun(), tStart, tEndFixed, fetchRequestResolution); req.setFilter(dsNames); FetchData data = req.fetchData(); defSources[i].setFetchData(data); for (int j = i + 1; j < defSources.length; j++) { if (defSources[i].isCompatibleWith(defSources[j])) { defSources[j].setFetchData(data); } } } } } }
/** * Plots up to date graphs of the gauge * @throws IOException */ public void graph() throws IOException { long currentTime = Util.getTime(); logger.debug("RRDRequestExecutionTimeGauge.graph()"); RrdDb rrdDb = new RrdDb(rrdFileName); RrdGraphDef graphDef = new RrdGraphDef(); graphDef.setVerticalLabel("exectime(ms)"); graphDef.setUnit("ms"); graphDef.datasource("exectime_avg", rrdFileName, "exectime", ConsolFun.AVERAGE); graphDef.line("exectime_avg", new Color(0xBB, 0, 0), "exectime_avg", 4); graphDef.datasource("exectime_max", rrdFileName, "exectime", ConsolFun.MAX); graphDef.line("exectime_max", new Color(0xFF, 0, 0), "exectime_max", 3); graphDef.datasource("exectime_min", rrdFileName, "exectime", ConsolFun.MIN); graphDef.line("exectime_min", new Color(0x90, 0x20, 0x20), "exectime_min", 2); //hour //graphDef.setStartTime(-hour); //#graphDef.setStartTime(-hour); plotGraph(graphDef,currentTime-FIVEMIN,currentTime,rrdFiveminImage); plotGraph(graphDef,currentTime-HOUR,currentTime,rrdHourlyImage); plotGraph(graphDef,currentTime-DAY,currentTime,rrdDaylyImage); plotGraph(graphDef,currentTime-MONTH,currentTime,rrdMounthlyImage); plotGraph(graphDef,currentTime-YEAR,currentTime,rrdYearlyImage); }
private void fetchRrdData() throws IOException { long tEndFixed = (tEnd == 0) ? Util.getTime() : tEnd; for (int i = 0; i < defSources.length; i++) { if (!defSources[i].isLoaded()) {
public static void main(String[] args) throws IOException { long start = Util.getTime(), end = start + 300 * 300; String rrdFile = Util.getRrd4jDemoPath("minmax.rrd"); String pngFile = Util.getRrd4jDemoPath("minmax.png");