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 9eb1bc6a5..e28486a11 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHandler.java @@ -20,11 +20,13 @@ public class ConfigStatsHandler extends FormHandler { private String _graphs; private boolean _explicitFilter; private String _explicitFilterValue; + private boolean _isFull; public ConfigStatsHandler() { super(); _stats = new ArrayList(); _explicitFilter = false; + _isFull = false; } protected void processForm() { @@ -70,6 +72,7 @@ public class ConfigStatsHandler extends FormHandler { public void setExplicitFilter(String foo) { _explicitFilter = true; } public void setExplicitFilterValue(String filter) { _explicitFilterValue = filter; } + public void setIsFull(String foo) { _isFull = true; } /** * The user made changes to the config and wants to save them, so @@ -109,6 +112,7 @@ public class ConfigStatsHandler extends FormHandler { _context.router().setConfigSetting(StatManager.PROP_STAT_FILTER, stats.toString()); _context.router().setConfigSetting("stat.summaries", _graphs); + _context.router().setConfigSetting(StatManager.PROP_STAT_FULL, "" + _isFull); boolean ok = _context.router().saveConfig(); if (ok) addFormNotice("Stat filter and location updated successfully to: " + stats.toString()); 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 bcad80274..8297a05ca 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigStatsHelper.java @@ -10,6 +10,7 @@ import java.util.StringTokenizer; import net.i2p.stat.Rate; import net.i2p.stat.RateStat; import net.i2p.stat.FrequencyStat; +import net.i2p.stat.StatManager; import net.i2p.router.RouterContext; import net.i2p.util.Log; @@ -141,4 +142,10 @@ public class ConfigStatsHelper { public boolean getCurrentIsGraphed() { return _currentIsGraphed; } public boolean getCurrentCanBeGraphed() { return _currentCanBeGraphed; } public String getExplicitFilter() { return _filter; } + public boolean getIsFull() { + String f = _context.getProperty(StatManager.PROP_STAT_FULL); + if (f != null && f.equals("true")) + return true; + return false; + } } diff --git a/apps/routerconsole/jsp/configstats.jsp b/apps/routerconsole/jsp/configstats.jsp index 6141f15e5..651636176 100644 --- a/apps/routerconsole/jsp/configstats.jsp +++ b/apps/routerconsole/jsp/configstats.jsp @@ -73,6 +73,10 @@ function toggleAll(category) System.setProperty("net.i2p.router.web.ConfigStatsHandler.nonce", new java.util.Random().nextLong()+""); %> " /> + Enable full stats? + checked="true" <% } %>/> + (change requires restart to take effect)
Stat file:
Filter: (toggle all)
diff --git a/core/java/src/net/i2p/stat/StatManager.java b/core/java/src/net/i2p/stat/StatManager.java index 98ee4a441..9d7635415 100644 --- a/core/java/src/net/i2p/stat/StatManager.java +++ b/core/java/src/net/i2p/stat/StatManager.java @@ -32,6 +32,22 @@ public class StatManager { public static final String PROP_STAT_FILTER = "stat.logFilters"; public static final String PROP_STAT_FILE = "stat.logFile"; public static final String DEFAULT_STAT_FILE = "stats.log"; + public static final String PROP_STAT_FULL = "stat.full"; + public static final String DEFAULT_STAT_FULL = "true"; + public static final String PROP_STAT_REQUIRED = "stat.required"; + /** + * These are all the stats published in netDb, plus those required for the operation of + * the router (many in RouterThrottleImpl), plus those that are on graphs.jsp by default. + * Wildcard ('*') allowed at end of stat only. + * Ignore all the rest of the stats unless stat.full=true. + */ + public static final String DEFAULT_STAT_REQUIRED = + "bw.recvRate,bw.sendBps,bw.sendRate,client.sendAckTime,clock.skew,crypto.elGamal.encrypt," + + "jobQueue.jobLag,netDb.successTime,router.fastPeers," + + "transport.receiveMessageSize,transport.sendMessageSize,transport.sendProcessingTime," + + "tunnel.buildRatio.*,tunnel.buildFailure,tunnel.buildSuccess,tunnel.corruptMessage," + + "tunnel.decryptRequestTime,tunnel.fragmentedDropped,tunnel.participatingMessageCount,"+ + "tunnel.participatingTunnels,tunnel.testFailedTime,tunnel.testSuccessTime" ; /** * The stat manager should only be constructed and accessed through the @@ -67,6 +83,7 @@ public class StatManager { * @param periods array of period lengths (in milliseconds) */ public void createFrequencyStat(String name, String description, String group, long periods[]) { + if (ignoreStat(name)) return; if (_frequencyStats.containsKey(name)) return; _frequencyStats.put(name, new FrequencyStat(name, description, group, periods)); } @@ -80,6 +97,7 @@ public class StatManager { * @param periods array of period lengths (in milliseconds) */ public void createRateStat(String name, String description, String group, long periods[]) { + if (ignoreStat(name)) return; synchronized (_rateStats) { if (_rateStats.containsKey(name)) return; RateStat rs = new RateStat(name, description, group, periods); @@ -165,4 +183,20 @@ public class StatManager { public String getStatFilter() { return _context.getProperty(PROP_STAT_FILTER); } public String getStatFile() { return _context.getProperty(PROP_STAT_FILE, DEFAULT_STAT_FILE); } + + // Save memory by not creating stats unless they are required for router operation + // Return true if the stat should be ignored. + public boolean ignoreStat(String statName) { + if (_context.getProperty(PROP_STAT_FULL, DEFAULT_STAT_FULL).equalsIgnoreCase("true")) + return false; + String required = _context.getProperty(PROP_STAT_REQUIRED, DEFAULT_STAT_REQUIRED); + String req[] = required.split(","); + for (int i=0; i