diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java
index 8965eabc8..9eb1bc6a5 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java
@@ -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 Graphs Page");
}
}
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHelper.java
index 0a46bdabd..bcad80274 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHelper.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHelper.java
@@ -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; }
}
diff --git a/apps/routerconsole/java/src/net/i2p/router/web/GraphHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/GraphHelper.java
index 55d27a69f..78da276b0 100644
--- a/apps/routerconsole/java/src/net/i2p/router/web/GraphHelper.java
+++ b/apps/routerconsole/java/src/net/i2p/router/web/GraphHelper.java
@@ -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("\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("