2007-07-16 zzz

* Make selection of graphed data configurable via configstats.jsp,
      remove most of the default graphs to save some memory
This commit is contained in:
zzz
2007-07-16 20:47:57 +00:00
committed by zzz
parent 5c1dc79767
commit 05b5df9d76
8 changed files with 98 additions and 35 deletions

View File

@ -17,6 +17,7 @@ import net.i2p.stat.StatManager;
public class ConfigStatsHandler extends FormHandler {
private String _filename;
private List _stats;
private String _graphs;
private boolean _explicitFilter;
private String _explicitFilterValue;
@ -48,6 +49,25 @@ public class ConfigStatsHandler extends FormHandler {
_log.debug("Updated stats: " + _stats);
}
public void setGraphList(String stats[]) {
if (stats != null) {
String s = "";
for (int i = 0; i < stats.length; i++) {
String cur = stats[i].trim();
if (cur.length() > 0) {
if (s.length() > 0)
s = s + ",";
s = s + cur;
}
}
_graphs = s;
} else {
_graphs = "";
}
if (_log.shouldLog(Log.DEBUG))
_log.debug("Updated graphs: " + _graphs);
}
public void setExplicitFilter(String foo) { _explicitFilter = true; }
public void setExplicitFilterValue(String filter) { _explicitFilterValue = filter; }
@ -88,11 +108,13 @@ public class ConfigStatsHandler extends FormHandler {
}
_context.router().setConfigSetting(StatManager.PROP_STAT_FILTER, stats.toString());
_context.router().setConfigSetting("stat.summaries", _graphs);
boolean ok = _context.router().saveConfig();
if (ok)
addFormNotice("Stat filter and location updated successfully to: " + stats.toString());
else
addFormError("Failed to update the stat filter and location");
addFormNotice("Graph list updated, may take up to 60s to be reflected here and on the <a href=\"graphs.jsp\">Graphs Page</a>");
}
}

View File

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import net.i2p.stat.Rate;
import net.i2p.stat.RateStat;
import net.i2p.stat.FrequencyStat;
import net.i2p.router.RouterContext;
@ -20,12 +21,15 @@ public class ConfigStatsHelper {
/** list of names of stats which are remaining, ordered by nested groups */
private List _stats;
private String _currentStatName;
private String _currentGraphName;
private String _currentStatDescription;
private String _currentGroup;
/** true if the current stat is the first in the group */
private boolean _currentIsFirstInGroup;
/** true if the stat is being logged */
private boolean _currentIsLogged;
private boolean _currentIsGraphed;
private boolean _currentCanBeGraphed;
/**
* Configure this bean to query a particular router context
@ -71,6 +75,7 @@ public class ConfigStatsHelper {
public boolean hasMoreStats() {
if (_stats.size() <= 0)
return false;
_currentIsGraphed = false;
_currentStatName = (String)_stats.remove(0);
RateStat rs = _context.statManager().getRate(_currentStatName);
if (rs != null) {
@ -82,6 +87,16 @@ public class ConfigStatsHelper {
else
_currentIsFirstInGroup = false;
_currentGroup = rs.getGroupName();
long period = rs.getPeriods()[0]; // should be the minimum
if (period <= 10*60*1000) {
Rate r = rs.getRate(period);
_currentCanBeGraphed = r != null;
if (_currentCanBeGraphed)
_currentIsGraphed = r.getSummaryListener() != null;
_currentGraphName = _currentStatName + "." + period;
} else {
_currentCanBeGraphed = false;
}
} else {
FrequencyStat fs = _context.statManager().getFrequency(_currentStatName);
if (fs != null) {
@ -93,6 +108,7 @@ public class ConfigStatsHelper {
else
_currentIsFirstInGroup = false;
_currentGroup = fs.getGroupName();
_currentCanBeGraphed = false;
} else {
if (_log.shouldLog(Log.ERROR))
_log.error("Stat does not exist?! [" + _currentStatName + "]");
@ -119,7 +135,10 @@ public class ConfigStatsHelper {
/** What group is the current stat in */
public String getCurrentGroupName() { return _currentGroup; }
public String getCurrentStatName() { return _currentStatName; }
public String getCurrentGraphName() { return _currentGraphName; }
public String getCurrentStatDescription() { return _currentStatDescription; }
public boolean getCurrentIsLogged() { return _currentIsLogged; }
public boolean getCurrentIsGraphed() { return _currentIsGraphed; }
public boolean getCurrentCanBeGraphed() { return _currentCanBeGraphed; }
public String getExplicitFilter() { return _filter; }
}

View File

@ -55,7 +55,21 @@ public class GraphHelper {
public String getImages() {
try {
if (!_showEvents)
List listeners = StatSummarizer.instance().getListeners();
TreeSet ordered = new TreeSet(new AlphaComparator());
ordered.addAll(listeners);
// go to some trouble to see if we have the data for the combined bw graph
boolean hasTx = false;
boolean hasRx = false;
for (Iterator iter = ordered.iterator(); iter.hasNext(); ) {
SummaryListener lsnr = (SummaryListener)iter.next();
String title = lsnr.getRate().getRateStat().getName();
if (title.equals("bw.sendRate")) hasTx = true;
else if (title.equals("bw.recvRate")) hasRx = true;
}
if (hasTx && hasRx && !_showEvents)
_out.write("<img width=\""
+ (_width + 83) + "\" height=\"" + (_height + 92)
+ "\" src=\"viewstat.jsp?stat=bw.combined"
@ -64,9 +78,6 @@ public class GraphHelper {
+ "&amp;height=" + (_height - 14)
+ "\" title=\"Combined bandwidth graph\" />\n");
List listeners = StatSummarizer.instance().getListeners();
TreeSet ordered = new TreeSet(new AlphaComparator());
ordered.addAll(listeners);
for (Iterator iter = ordered.iterator(); iter.hasNext(); ) {
SummaryListener lsnr = (SummaryListener)iter.next();
Rate r = lsnr.getRate();
@ -92,6 +103,7 @@ public class GraphHelper {
}
public String getForm() {
try {
_out.write("<p /><a href=\"configstats.jsp\">Select Stats to Graph</a><p />");
_out.write("<form action=\"graphs.jsp\" method=\"GET\">");
_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\" ") + " /> ");

View File

@ -45,27 +45,27 @@ public class StatSummarizer implements Runnable {
private static final String DEFAULT_DATABASES = "bw.sendRate.60000" +
",bw.recvRate.60000" +
",tunnel.testSuccessTime.60000" +
",udp.outboundActiveCount.60000" +
",udp.receivePacketSize.60000" +
",udp.receivePacketSkew.60000" +
",udp.sendConfirmTime.60000" +
",udp.sendPacketSize.60000" +
",router.activePeers.60000" +
",router.activeSendPeers.60000" +
",tunnel.acceptLoad.60000" +
",tunnel.dropLoadProactive.60000" +
",tunnel.buildExploratorySuccess.60000" +
",tunnel.buildExploratoryReject.60000" +
",tunnel.buildExploratoryExpire.60000" +
",client.sendAckTime.60000" +
",client.dispatchNoACK.60000" +
",ntcp.sendTime.60000" +
",ntcp.transmitTime.60000" +
",ntcp.sendBacklogTime.60000" +
",ntcp.receiveTime.60000" +
",transport.sendMessageFailureLifetime.60000" +
",transport.sendProcessingTime.60000";
// ",tunnel.testSuccessTime.60000" +
// ",udp.outboundActiveCount.60000" +
// ",udp.receivePacketSize.60000" +
// ",udp.receivePacketSkew.60000" +
// ",udp.sendConfirmTime.60000" +
// ",udp.sendPacketSize.60000" +
",router.activePeers.60000";
// ",router.activeSendPeers.60000" +
// ",tunnel.acceptLoad.60000" +
// ",tunnel.dropLoadProactive.60000" +
// ",tunnel.buildExploratorySuccess.60000" +
// ",tunnel.buildExploratoryReject.60000" +
// ",tunnel.buildExploratoryExpire.60000" +
// ",client.sendAckTime.60000" +
// ",client.dispatchNoACK.60000" +
// ",ntcp.sendTime.60000" +
// ",ntcp.transmitTime.60000" +
// ",ntcp.sendBacklogTime.60000" +
// ",ntcp.receiveTime.60000" +
// ",transport.sendMessageFailureLifetime.60000" +
// ",transport.sendProcessingTime.60000";
private String adjustDatabases(String oldSpecs) {
String spec = _context.getProperty("stat.summaries", DEFAULT_DATABASES);

View File

@ -184,7 +184,9 @@ class SummaryRenderer {
RrdGraphDef def = new RrdGraphDef();
def.setTimePeriod(start/1000, 0);
String name = _listener.getRate().getRateStat().getName();
if ((name.startsWith("bw.") || name.endsWith("PacketSize")) && !showEvents)
// heuristic to set K=1024
if ((name.startsWith("bw.") || name.indexOf("Size") >= 0 || name.indexOf("Bps") >= 0)
&& !showEvents)
def.setBaseValue(1024);
String title = name;
if (showEvents)

View File

@ -78,22 +78,26 @@ function toggleAll(category)
<table>
<% while (statshelper.hasMoreStats()) {
while (statshelper.groupRequired()) { %>
<tr><td valign="top" align="left" colspan="2">
<tr><td valign="top" align="left" colspan="3">
<b><%=statshelper.getCurrentGroupName()%></b>
(<a href="javascript: void(null);" onclick="toggleAll('<%=statshelper.getCurrentGroupName()%>')">toggle all</a>)
</td></tr><%
</td></tr><tr><td>Log</td><td>Graph</td><td></td></tr><%
} // end iterating over required groups for the current stat %>
<tr><td valign="top" align="left">
<input id="<%=statshelper.getCurrentGroupName()%>" type="checkbox" name="statList" value="<%=statshelper.getCurrentStatName()%>" <%
if (statshelper.getCurrentIsLogged()) { %>checked="true" <% } %>/></td>
<td valign="top" align="left">
<% if (statshelper.getCurrentCanBeGraphed()) { %>
<input id="<%=statshelper.getCurrentGroupName()%>" type="checkbox" name="graphList" value="<%=statshelper.getCurrentGraphName()%>" <%
if (statshelper.getCurrentIsGraphed()) { %>checked="true" <% } %>/><% } %></td>
<td valign="top" align="left"><b><%=statshelper.getCurrentStatName()%>:</b><br />
<%=statshelper.getCurrentStatDescription()%></td></tr><%
} // end iterating over all stats %>
<tr><td colspan="2"><hr /></td></tr>
<tr><td colspan="3"><hr /></td></tr>
<tr><td><input type="checkbox" name="explicitFilter" /></td>
<td>Advanced filter:
<td colspan="2">Advanced filter:
<input type="text" name="explicitFilterValue" value="<%=statshelper.getExplicitFilter()%>" size="40" /></td></tr>
<tr><td colspan="2"><hr /></td></tr>
<tr><td colspan="3"><hr /></td></tr>
<tr><td><input type="submit" name="shouldsave" value="Save changes" /> </td>
<td><input type="reset" value="Cancel" /></td></tr>
</form>

View File

@ -1,4 +1,8 @@
$Id: history.txt,v 1.576 2007-07-14 19:56:18 complication Exp $
$Id: history.txt,v 1.577 2007-07-15 13:34:33 zzz Exp $
2007-07-16 zzz
* Make selection of graphed data configurable via configstats.jsp,
remove most of the default graphs to save some memory
2007-07-15 zzz
* Add current values to graph legends

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.511 $ $Date: 2007-07-14 19:56:20 $";
public final static String ID = "$Revision: 1.512 $ $Date: 2007-07-15 13:34:34 $";
public final static String VERSION = "0.6.1.28";
public final static long BUILD = 14;
public final static long BUILD = 15;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID);