forked from I2P_Developers/i2p.i2p
1st cut
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
<pathelement location="../../systray/java/lib/systray4j.jar" />
|
||||
<pathelement location="../../desktopgui/build" />
|
||||
<pathelement location="../../../installer/lib/wrapper/win32/wrapper.jar" /> <!-- we dont care if we're not on win32 -->
|
||||
<pathelement location="../../jrobin/jrobin-1.4.0.jar" />
|
||||
<pathelement location="../../jrobin/jrobin-1.5.9.jar" />
|
||||
</classpath>
|
||||
</depend>
|
||||
</target>
|
||||
@ -58,7 +58,7 @@
|
||||
<pathelement location="../../systray/java/lib/systray4j.jar" />
|
||||
<pathelement location="../../desktopgui/dist/desktopgui.jar" />
|
||||
<pathelement location="../../../installer/lib/wrapper/win32/wrapper.jar" /> <!-- we dont care if we're not on win32 -->
|
||||
<pathelement location="../../jrobin/jrobin-1.4.0.jar" />
|
||||
<pathelement location="../../jrobin/jrobin-1.5.9.jar" />
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
@ -92,7 +92,7 @@
|
||||
</jar>
|
||||
<!-- jrobin taken out of routerconsole.jar in 0.7.12
|
||||
<delete dir="./tmpextract" />
|
||||
<unjar src="../../jrobin/jrobin-1.4.0.jar" dest="./tmpextract" />
|
||||
<unjar src="../../jrobin/jrobin-1.5.9.jar" dest="./tmpextract" />
|
||||
<jar destfile="./build/routerconsole.jar" basedir="./tmpextract" update="true" />
|
||||
<delete dir="./tmpextract" />
|
||||
-->
|
||||
|
@ -23,8 +23,8 @@ public class GraphHelper extends FormHandler {
|
||||
private static final String PROP_REFRESH = "routerconsole.graphRefresh";
|
||||
private static final String PROP_PERIODS = "routerconsole.graphPeriods";
|
||||
private static final String PROP_EVENTS = "routerconsole.graphEvents";
|
||||
private static final int DEFAULT_X = 250;
|
||||
private static final int DEFAULT_Y = 100;
|
||||
public static final int DEFAULT_X = 250;
|
||||
public static final int DEFAULT_Y = 100;
|
||||
private static final int DEFAULT_REFRESH = 60;
|
||||
private static final int DEFAULT_PERIODS = 60;
|
||||
static final int MAX_X = 2048;
|
||||
@ -91,12 +91,11 @@ public class GraphHelper extends FormHandler {
|
||||
+ "&height=" + (3 * _height)
|
||||
+ "\" target=\"_blank\">");
|
||||
String title = _("Combined bandwidth graph");
|
||||
_out.write("<img class=\"statimage\" width=\""
|
||||
+ (_width + 83) + "\" height=\"" + (_height + 92)
|
||||
+ "\" src=\"viewstat.jsp?stat=bw.combined"
|
||||
_out.write("<img class=\"statimage\""
|
||||
+ " src=\"viewstat.jsp?stat=bw.combined"
|
||||
+ "&periodCount=" + _periodCount
|
||||
+ "&width=" + _width
|
||||
+ "&height=" + (_height - 14)
|
||||
+ "&height=" + (_height - 13)
|
||||
+ "\" alt=\"" + title + "\" title=\"" + title + "\"></a>\n");
|
||||
}
|
||||
|
||||
@ -113,9 +112,8 @@ public class GraphHelper extends FormHandler {
|
||||
+ "&width=" + (3 * _width)
|
||||
+ "&height=" + (3 * _height)
|
||||
+ "\" target=\"_blank\">");
|
||||
_out.write("<img class=\"statimage\" border=\"0\" width=\""
|
||||
+ (_width + 83) + "\" height=\"" + (_height + 92)
|
||||
+ "\" src=\"viewstat.jsp?stat="
|
||||
_out.write("<img class=\"statimage\" border=\"0\""
|
||||
+ " src=\"viewstat.jsp?stat="
|
||||
+ r.getRateStat().getName()
|
||||
+ "&showEvents=" + _showEvents
|
||||
+ "&period=" + r.getPeriod()
|
||||
|
@ -1,6 +1,8 @@
|
||||
package net.i2p.router.web;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
@ -8,6 +10,10 @@ import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import javax.imageio.stream.MemoryCacheImageOutputStream;
|
||||
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.stat.Rate;
|
||||
import net.i2p.stat.RateStat;
|
||||
@ -122,7 +128,8 @@ public class StatSummarizer implements Runnable {
|
||||
}
|
||||
|
||||
public boolean renderPng(Rate rate, OutputStream out) throws IOException {
|
||||
return renderPng(rate, out, -1, -1, false, false, false, false, -1, true);
|
||||
return renderPng(rate, out, GraphHelper.DEFAULT_X, GraphHelper.DEFAULT_Y,
|
||||
false, false, false, false, -1, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,8 +157,12 @@ public class StatSummarizer implements Runnable {
|
||||
boolean showCredit) throws IOException {
|
||||
if (width > GraphHelper.MAX_X)
|
||||
width = GraphHelper.MAX_X;
|
||||
else if (width <= 0)
|
||||
width = GraphHelper.DEFAULT_X;
|
||||
if (height > GraphHelper.MAX_Y)
|
||||
height = GraphHelper.MAX_Y;
|
||||
else if (height <= 0)
|
||||
height = GraphHelper.DEFAULT_Y;
|
||||
for (int i = 0; i < _listeners.size(); i++) {
|
||||
SummaryListener lsnr = _listeners.get(i);
|
||||
if (lsnr.getRate().equals(rate)) {
|
||||
@ -162,6 +173,7 @@ public class StatSummarizer implements Runnable {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @deprecated unused */
|
||||
public boolean renderPng(OutputStream out, String templateFilename) throws IOException {
|
||||
SummaryRenderer.render(_context, out, templateFilename);
|
||||
return true;
|
||||
@ -206,8 +218,12 @@ public class StatSummarizer implements Runnable {
|
||||
long end = _context.clock().now() - 60*1000;
|
||||
if (width > GraphHelper.MAX_X)
|
||||
width = GraphHelper.MAX_X;
|
||||
else if (width <= 0)
|
||||
width = GraphHelper.DEFAULT_X;
|
||||
if (height > GraphHelper.MAX_Y)
|
||||
height = GraphHelper.MAX_Y;
|
||||
else if (height <= 0)
|
||||
height = GraphHelper.DEFAULT_Y;
|
||||
if (periodCount <= 0) periodCount = SummaryListener.PERIODS;
|
||||
if (periodCount > SummaryListener.PERIODS)
|
||||
periodCount = SummaryListener.PERIODS;
|
||||
@ -216,9 +232,9 @@ public class StatSummarizer implements Runnable {
|
||||
//long begin = System.currentTimeMillis();
|
||||
try {
|
||||
RrdGraphDef def = new RrdGraphDef();
|
||||
def.setTimePeriod(start/1000, 0);
|
||||
def.setLowerLimit(0d);
|
||||
def.setBaseValue(1024);
|
||||
def.setTimeSpan(start/1000, end/1000);
|
||||
def.setMinValue(0d);
|
||||
def.setBase(1024);
|
||||
// Note to translators: all runtime zh translation disabled in this file, no font available in RRD
|
||||
String title = _("Bandwidth usage");
|
||||
if (!hideTitle)
|
||||
@ -227,37 +243,41 @@ public class StatSummarizer implements Runnable {
|
||||
String recvName = SummaryListener.createName(_context, "bw.recvRate.60000");
|
||||
def.datasource(sendName, sendName, sendName, "AVERAGE", "MEMORY");
|
||||
def.datasource(recvName, recvName, recvName, "AVERAGE", "MEMORY");
|
||||
def.area(sendName, Color.BLUE, _("Outbound bytes/sec"));
|
||||
def.area(sendName, Color.BLUE, _("Outbound Bytes/sec"));
|
||||
//def.line(sendName, Color.BLUE, "Outbound bytes/sec", 3);
|
||||
def.line(recvName, Color.RED, _("Inbound bytes/sec") + "@r", 3);
|
||||
def.line(recvName, Color.RED, _("Inbound Bytes/sec") + "\\r", 3);
|
||||
//def.area(recvName, Color.RED, "Inbound bytes/sec@r");
|
||||
if (!hideLegend) {
|
||||
def.gprint(sendName, "AVERAGE", _("out average") + ": @2@s" + _("bytes/sec"));
|
||||
def.gprint(sendName, "MAX", ' ' + _("max") + ": @2@s" + _("bytes/sec") + "@r");
|
||||
def.gprint(recvName, "AVERAGE", _("in average") + ": @2@s" + _("bytes/sec"));
|
||||
def.gprint(recvName, "MAX", ' ' + _("max") + ": @2@s" + _("bytes/sec") + "@r");
|
||||
def.gprint(sendName, "AVERAGE", _("Out average") + ": %.2f %s" + _("Bps"));
|
||||
def.gprint(sendName, "MAX", ' ' + _("max") + ": %.2f %S" + _("Bps") + "\\r");
|
||||
def.gprint(recvName, "AVERAGE", _("In average") + ": %.2f %S" + _("Bps"));
|
||||
def.gprint(recvName, "MAX", ' ' + _("max") + ": %.2f %S" + _("Bps") + "\\r");
|
||||
}
|
||||
if (!showCredit)
|
||||
def.setShowSignature(false);
|
||||
if (hideLegend)
|
||||
def.setShowLegend(false);
|
||||
def.setNoLegend(true);
|
||||
if (hideGrid) {
|
||||
def.setGridX(false);
|
||||
def.setGridY(false);
|
||||
def.setDrawXGrid(false);
|
||||
def.setDrawYGrid(false);
|
||||
}
|
||||
//System.out.println("rendering: path=" + path + " dsNames[0]=" + dsNames[0] + " dsNames[1]=" + dsNames[1] + " lsnr.getName=" + _listener.getName());
|
||||
def.setAntiAliasing(false);
|
||||
//System.out.println("Rendering: \n" + def.exportXmlTemplate());
|
||||
//System.out.println("*****************\nData: \n" + _listener.getData().dump());
|
||||
def.setWidth(width);
|
||||
def.setHeight(height);
|
||||
|
||||
RrdGraph graph = new RrdGraph(def);
|
||||
//System.out.println("Graph created");
|
||||
byte data[] = null;
|
||||
if ( (width <= 0) || (height <= 0) )
|
||||
data = graph.getPNGBytes();
|
||||
else
|
||||
data = graph.getPNGBytes(width, height);
|
||||
//long timeToPlot = System.currentTimeMillis() - begin;
|
||||
out.write(data);
|
||||
int totalWidth = graph.getRrdGraphInfo().getWidth();
|
||||
int totalHeight = graph.getRrdGraphInfo().getHeight();
|
||||
BufferedImage img = new BufferedImage(totalWidth, totalHeight, BufferedImage.TYPE_USHORT_565_RGB);
|
||||
Graphics gfx = img.getGraphics();
|
||||
graph.render(gfx);
|
||||
ImageOutputStream ios = new MemoryCacheImageOutputStream(out);
|
||||
ImageIO.write(img, "png", ios);
|
||||
|
||||
//File t = File.createTempFile("jrobinData", ".xml");
|
||||
//_listener.getData().dumpXml(new FileOutputStream(t));
|
||||
//System.out.println("plotted: " + (data != null ? data.length : 0) + " bytes in " + timeToPlot
|
||||
|
@ -1,9 +1,16 @@
|
||||
package net.i2p.router.web;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import javax.imageio.stream.MemoryCacheImageOutputStream;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.stat.Rate;
|
||||
@ -38,6 +45,7 @@ class SummaryRenderer {
|
||||
* DOM level 3 load and store support. Perhaps we can bundle that, or
|
||||
* specify who can get it from where, etc.
|
||||
*
|
||||
* @deprecated unsed
|
||||
*/
|
||||
public static synchronized void render(I2PAppContext ctx, OutputStream out, String filename) throws IOException {
|
||||
long end = ctx.clock().now() - 60*1000;
|
||||
@ -45,10 +53,21 @@ class SummaryRenderer {
|
||||
try {
|
||||
RrdGraphDefTemplate template = new RrdGraphDefTemplate(filename);
|
||||
RrdGraphDef def = template.getRrdGraphDef();
|
||||
def.setTimePeriod(start/1000, end/1000); // ignore the periods in the template
|
||||
def.setTimeSpan(start/1000, end/1000); // ignore the periods in the template
|
||||
// FIXME not clear how to get the height and width from the template
|
||||
int width = GraphHelper.DEFAULT_X;
|
||||
int height = GraphHelper.DEFAULT_Y;
|
||||
def.setWidth(width);
|
||||
def.setHeight(height);
|
||||
|
||||
RrdGraph graph = new RrdGraph(def);
|
||||
byte img[] = graph.getPNGBytes();
|
||||
out.write(img);
|
||||
int totalWidth = graph.getRrdGraphInfo().getWidth();
|
||||
int totalHeight = graph.getRrdGraphInfo().getHeight();
|
||||
BufferedImage img = new BufferedImage(totalWidth, totalHeight, BufferedImage.TYPE_USHORT_565_RGB);
|
||||
Graphics gfx = img.getGraphics();
|
||||
graph.render(gfx);
|
||||
ImageOutputStream ios = new MemoryCacheImageOutputStream(out);
|
||||
ImageIO.write(img, "png", ios);
|
||||
} catch (RrdException re) {
|
||||
//_log.error("Error rendering " + filename, re);
|
||||
throw new IOException("Error plotting: " + re.getMessage());
|
||||
@ -58,7 +77,8 @@ class SummaryRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
public void render(OutputStream out) throws IOException { render(out, -1, -1, false, false, false, false, -1, false); }
|
||||
public void render(OutputStream out) throws IOException { render(out, GraphHelper.DEFAULT_X, GraphHelper.DEFAULT_Y,
|
||||
false, false, false, false, -1, false); }
|
||||
|
||||
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() - 60*1000;
|
||||
@ -69,13 +89,13 @@ class SummaryRenderer {
|
||||
//long begin = System.currentTimeMillis();
|
||||
try {
|
||||
RrdGraphDef def = new RrdGraphDef();
|
||||
def.setTimePeriod(start/1000, 0);
|
||||
def.setLowerLimit(0d);
|
||||
def.setTimeSpan(start/1000, end/1000);
|
||||
def.setMinValue(0d);
|
||||
String name = _listener.getRate().getRateStat().getName();
|
||||
// heuristic to set K=1024
|
||||
if ((name.startsWith("bw.") || name.indexOf("Size") >= 0 || name.indexOf("Bps") >= 0 || name.indexOf("memory") >= 0)
|
||||
&& !showEvents)
|
||||
def.setBaseValue(1024);
|
||||
def.setBase(1024);
|
||||
if (!hideTitle) {
|
||||
String title;
|
||||
String p;
|
||||
@ -109,11 +129,11 @@ class SummaryRenderer {
|
||||
descr = _(_listener.getRate().getRateStat().getDescription());
|
||||
}
|
||||
def.datasource(plotName, path, plotName, "AVERAGE", "MEMORY");
|
||||
def.area(plotName, Color.BLUE, descr + "@r");
|
||||
def.area(plotName, Color.BLUE, descr + "\\r");
|
||||
if (!hideLegend) {
|
||||
def.gprint(plotName, "AVERAGE", _("avg") + ": @2@s");
|
||||
def.gprint(plotName, "MAX", ' ' + _("max") + ": @2@s");
|
||||
def.gprint(plotName, "LAST", ' ' + _("now") + ": @2@s@r");
|
||||
def.gprint(plotName, "AVERAGE", _("avg") + ": %.2f %s");
|
||||
def.gprint(plotName, "MAX", ' ' + _("max") + ": %.2f %S");
|
||||
def.gprint(plotName, "LAST", ' ' + _("now") + ": %.2f %S\\r");
|
||||
}
|
||||
if (!showCredit)
|
||||
def.setShowSignature(false);
|
||||
@ -126,24 +146,28 @@ class SummaryRenderer {
|
||||
def.line(dsNames[1], Color.RED, "Events per period");
|
||||
*/
|
||||
if (hideLegend)
|
||||
def.setShowLegend(false);
|
||||
def.setNoLegend(true);
|
||||
if (hideGrid) {
|
||||
def.setGridX(false);
|
||||
def.setGridY(false);
|
||||
def.setDrawXGrid(false);
|
||||
def.setDrawYGrid(false);
|
||||
}
|
||||
//System.out.println("rendering: path=" + path + " dsNames[0]=" + dsNames[0] + " dsNames[1]=" + dsNames[1] + " lsnr.getName=" + _listener.getName());
|
||||
def.setAntiAliasing(false);
|
||||
//System.out.println("Rendering: \n" + def.exportXmlTemplate());
|
||||
//System.out.println("*****************\nData: \n" + _listener.getData().dump());
|
||||
def.setWidth(width);
|
||||
def.setHeight(height);
|
||||
|
||||
RrdGraph graph = new RrdGraph(def);
|
||||
int totalWidth = graph.getRrdGraphInfo().getWidth();
|
||||
int totalHeight = graph.getRrdGraphInfo().getHeight();
|
||||
BufferedImage img = new BufferedImage(totalWidth, totalHeight, BufferedImage.TYPE_USHORT_565_RGB);
|
||||
Graphics gfx = img.getGraphics();
|
||||
graph.render(gfx);
|
||||
ImageOutputStream ios = new MemoryCacheImageOutputStream(out);
|
||||
ImageIO.write(img, "png", ios);
|
||||
//System.out.println("Graph created");
|
||||
byte data[] = null;
|
||||
if ( (width <= 0) || (height <= 0) )
|
||||
data = graph.getPNGBytes();
|
||||
else
|
||||
data = graph.getPNGBytes(width, height);
|
||||
//long timeToPlot = System.currentTimeMillis() - begin;
|
||||
out.write(data);
|
||||
|
||||
//File t = File.createTempFile("jrobinData", ".xml");
|
||||
//_listener.getData().dumpXml(new FileOutputStream(t));
|
||||
//System.out.println("plotted: " + (data != null ? data.length : 0) + " bytes in " + timeToPlot
|
||||
|
Reference in New Issue
Block a user