forked from I2P_Developers/i2p.i2p

* Integrate basic hooks for jrobin (http://jrobin.org) into the router console. Selected stats can be harvested automatically and fed into in-memory RRD databases, and those databases can be served up either as PNG images or as RRDtool compatible XML dumps (see oldstats.jsp for details). A base set of stats are harvested by default, but an alternate list can be specified by setting the 'stat.summaries' list on the advanced config. For instance: stat.summaries=bw.recvRate.60000,bw.sendRate.60000 * HTML tweaking for the general config page (thanks void!) * Odd NPE fix (thanks Complication!)
37 lines
1.4 KiB
Plaintext
37 lines
1.4 KiB
Plaintext
<%
|
|
net.i2p.stat.Rate rate = null;
|
|
String stat = request.getParameter("stat");
|
|
String period = request.getParameter("period");
|
|
net.i2p.stat.RateStat rs = net.i2p.I2PAppContext.getGlobalContext().statManager().getRate(stat);
|
|
boolean rendered = false;
|
|
if (rs != null) {
|
|
long per = -1;
|
|
try {
|
|
per = Long.parseLong(period);
|
|
rate = rs.getRate(per);
|
|
if (rate != null) {
|
|
java.io.OutputStream cout = response.getOutputStream();
|
|
String format = request.getParameter("format");
|
|
if ("xml".equals(format)) {
|
|
response.setContentType("text/xml");
|
|
rendered = net.i2p.router.web.StatSummarizer.instance().getXML(rate, cout);
|
|
} else {
|
|
response.setContentType("image/png");
|
|
int width = -1;
|
|
int height = -1;
|
|
String str = request.getParameter("width");
|
|
if (str != null) try { width = Integer.parseInt(str); } catch (NumberFormatException nfe) {}
|
|
str = request.getParameter("height");
|
|
if (str != null) try { height = Integer.parseInt(str); } catch (NumberFormatException nfe) {}
|
|
rendered = net.i2p.router.web.StatSummarizer.instance().renderPng(rate, cout, width, height);
|
|
}
|
|
if (rendered)
|
|
cout.close();
|
|
//System.out.println("Rendered period " + per + " for the stat " + stat + "? " + rendered);
|
|
}
|
|
} catch (NumberFormatException nfe) {}
|
|
}
|
|
if (!rendered) {
|
|
response.sendError(404, "That stat is not available");
|
|
}
|
|
%> |