forked from I2P_Developers/i2p.i2p
2006-03-20 jrandom
* Fix to allow for some slack when coalescing stats * Workaround some oddball errors
This commit is contained in:
@ -31,10 +31,10 @@ public class GraphHelper {
|
||||
}
|
||||
|
||||
public GraphHelper() {
|
||||
_periodCount = SummaryListener.PERIODS;
|
||||
_periodCount = 60; // SummaryListener.PERIODS;
|
||||
_showEvents = false;
|
||||
_width = -1;
|
||||
_height = -1;
|
||||
_width = 250;
|
||||
_height = 100;
|
||||
_refreshDelaySeconds = 60;
|
||||
}
|
||||
|
||||
@ -79,12 +79,12 @@ public class GraphHelper {
|
||||
public String getForm() {
|
||||
try {
|
||||
_out.write("<form action=\"graphs.jsp\" method=\"GET\">");
|
||||
_out.write("Periods: <input type=\"text\" name=\"periodCount\" value=\"" + _periodCount + "\" /><br />\n");
|
||||
_out.write("Periods: <input size=\"3\" type=\"text\" name=\"periodCount\" value=\"" + _periodCount + "\" /><br />\n");
|
||||
_out.write("Plot averages: <input type=\"radio\" name=\"showEvents\" value=\"false\" " + (_showEvents ? "" : "checked=\"true\" ") + " /> ");
|
||||
_out.write("or plot events: <input type=\"radio\" name=\"showEvents\" value=\"true\" "+ (_showEvents ? "checked=\"true\" " : "") + " /><br />\n");
|
||||
_out.write("Image sizes: width: <input size=\"4\" type=\"text\" name=\"width\" value=\"" + _width
|
||||
+ "\" /> pixels, height: <input size=\"4\" type=\"text\" name=\"height\" value=\"" + _height
|
||||
+ "\" /> (-1 for the default) <br />\n");
|
||||
+ "\" /><br />\n");
|
||||
_out.write("Refresh delay: <select name=\"refreshDelay\"><option value=\"60\">1 minute</option><option value=\"120\">2 minutes</option><option value=\"300\">5 minutes</option><option value=\"600\">10 minutes</option><option value=\"-1\">Never</option></select><br />\n");
|
||||
_out.write("<input type=\"submit\" value=\"Redraw\" />");
|
||||
} catch (IOException ioe) {
|
||||
|
@ -43,7 +43,10 @@ public class StatSummarizer implements Runnable {
|
||||
",udp.sendConfirmTime.60000" +
|
||||
",udp.sendPacketSize.60000" +
|
||||
",router.activePeers.60000" +
|
||||
",router.activeSendPeers.60000";
|
||||
",router.activeSendPeers.60000" +
|
||||
",tunnel.acceptLoad.60000" +
|
||||
",client.sendAckTime.60000" +
|
||||
",client.dispatchNoACK.60000";
|
||||
|
||||
private String adjustDatabases(String oldSpecs) {
|
||||
String spec = _context.getProperty("stat.summaries", DEFAULT_DATABASES);
|
||||
@ -90,13 +93,13 @@ public class StatSummarizer implements Runnable {
|
||||
//System.out.println("Start listening for " + r.getRateStat().getName() + ": " + r.getPeriod());
|
||||
}
|
||||
public boolean renderPng(Rate rate, OutputStream out) throws IOException {
|
||||
return renderPng(rate, out, -1, -1, false, false, false, false, -1);
|
||||
return renderPng(rate, out, -1, -1, false, false, false, false, -1, true);
|
||||
}
|
||||
public boolean renderPng(Rate rate, OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount) throws IOException {
|
||||
public boolean renderPng(Rate rate, OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, boolean showCredit) throws IOException {
|
||||
for (int i = 0; i < _listeners.size(); i++) {
|
||||
SummaryListener lsnr = (SummaryListener)_listeners.get(i);
|
||||
if (lsnr.getRate().equals(rate)) {
|
||||
lsnr.renderPng(out, width, height, hideLegend, hideGrid, hideTitle, showEvents, periodCount);
|
||||
lsnr.renderPng(out, width, height, hideLegend, hideGrid, hideTitle, showEvents, periodCount, showCredit);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class SummaryListener implements RateSummaryListener {
|
||||
private RrdMemoryBackendFactory _factory;
|
||||
private SummaryRenderer _renderer;
|
||||
|
||||
static final int PERIODS = 600;
|
||||
static final int PERIODS = 1440;
|
||||
|
||||
static {
|
||||
try {
|
||||
@ -49,10 +49,13 @@ class SummaryListener implements RateSummaryListener {
|
||||
}
|
||||
|
||||
public void add(double totalValue, long eventCount, double totalEventTime, long period) {
|
||||
long now = now();
|
||||
long when = now / 1000;
|
||||
//System.out.println("add to " + getRate().getRateStat().getName() + " on " + System.currentTimeMillis() + " / " + now + " / " + when);
|
||||
if (_db != null) {
|
||||
// add one value to the db (the average value for the period)
|
||||
try {
|
||||
_sample.setTime(now()/1000);
|
||||
_sample.setTime(when);
|
||||
double val = eventCount > 0 ? (totalValue / (double)eventCount) : 0d;
|
||||
_sample.setValue(_name, val);
|
||||
_sample.setValue(_eventName, eventCount);
|
||||
@ -88,10 +91,12 @@ class SummaryListener implements RateSummaryListener {
|
||||
_eventName = createName(_context, baseName + ".events");
|
||||
try {
|
||||
RrdDef def = new RrdDef(_name, now()/1000, period/1000);
|
||||
long heartbeat = period*3/1000; // max seconds between events
|
||||
// for info on the heartbeat, xff, steps, etc, see the rrdcreate man page, aka
|
||||
// http://www.jrobin.org/support/man/rrdcreate.html
|
||||
long heartbeat = period*10/1000;
|
||||
def.addDatasource(_name, "GAUGE", heartbeat, Double.NaN, Double.NaN);
|
||||
def.addDatasource(_eventName, "GAUGE", heartbeat, 0, Double.NaN);
|
||||
double xff = 0.5;
|
||||
double xff = 0.9;
|
||||
int steps = 1;
|
||||
int rows = PERIODS;
|
||||
def.addArchive("AVERAGE", xff, steps, rows);
|
||||
@ -117,8 +122,8 @@ class SummaryListener implements RateSummaryListener {
|
||||
_factory.delete(_db.getPath());
|
||||
_db = null;
|
||||
}
|
||||
public void renderPng(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount) throws IOException {
|
||||
_renderer.render(out, width, height, hideLegend, hideGrid, hideTitle, showEvents, periodCount);
|
||||
public void renderPng(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, boolean showCredit) throws IOException {
|
||||
_renderer.render(out, width, height, hideLegend, hideGrid, hideTitle, showEvents, periodCount, showCredit);
|
||||
}
|
||||
public void renderPng(OutputStream out) throws IOException { _renderer.render(out); }
|
||||
|
||||
@ -167,8 +172,8 @@ class SummaryRenderer {
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
public void render(OutputStream out) throws IOException { render(out, -1, -1, false, false, false, false, -1); }
|
||||
public void render(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount) throws IOException {
|
||||
public void render(OutputStream out) throws IOException { render(out, -1, -1, false, false, false, false, -1, true); }
|
||||
public void render(OutputStream out, int width, int height, boolean hideLegend, boolean hideGrid, boolean hideTitle, boolean showEvents, int periodCount, boolean showCredit) throws IOException {
|
||||
long end = _listener.now();
|
||||
if (periodCount <= 0) periodCount = SummaryListener.PERIODS;
|
||||
if (periodCount > SummaryListener.PERIODS)
|
||||
@ -201,6 +206,8 @@ class SummaryRenderer {
|
||||
def.gprint(plotName, "AVERAGE", "average: @2@s");
|
||||
def.gprint(plotName, "MAX", " max: @2@s@r");
|
||||
}
|
||||
if (!showCredit)
|
||||
def.setShowSignature(false);
|
||||
/*
|
||||
// these four lines set up a graph plotting both values and events on the same chart
|
||||
// (but with the same coordinates, so the values may look pretty skewed)
|
||||
@ -220,7 +227,7 @@ class SummaryRenderer {
|
||||
//System.out.println("Rendering: \n" + def.exportXmlTemplate());
|
||||
//System.out.println("*****************\nData: \n" + _listener.getData().dump());
|
||||
RrdGraph graph = new RrdGraph(def);
|
||||
System.out.println("Graph created");
|
||||
//System.out.println("Graph created");
|
||||
byte data[] = null;
|
||||
if ( (width <= 0) || (height <= 0) )
|
||||
data = graph.getPNGBytes();
|
||||
|
Reference in New Issue
Block a user