stats.jsp tagging

This commit is contained in:
zzz
2009-12-19 17:41:47 +00:00
parent 2a1d358141
commit 9bf22fb0d3
2 changed files with 36 additions and 12 deletions

View File

@ -40,7 +40,7 @@ public class StatsGenerator {
String group = (String)entry.getKey(); String group = (String)entry.getKey();
Set stats = (Set)entry.getValue(); Set stats = (Set)entry.getValue();
buf.append("<option value=\"/stats.jsp#").append(group).append("\">"); buf.append("<option value=\"/stats.jsp#").append(group).append("\">");
buf.append(group).append("</option>\n"); buf.append(_(group)).append("</option>\n");
for (Iterator statIter = stats.iterator(); statIter.hasNext(); ) { for (Iterator statIter = stats.iterator(); statIter.hasNext(); ) {
String stat = (String)statIter.next(); String stat = (String)statIter.next();
buf.append("<option value=\"/stats.jsp#"); buf.append("<option value=\"/stats.jsp#");
@ -52,7 +52,7 @@ public class StatsGenerator {
out.write(buf.toString()); out.write(buf.toString());
buf.setLength(0); buf.setLength(0);
} }
buf.append("</select> <input type=\"submit\" value=\"GO\" />"); buf.append("</select> <input type=\"submit\" value=\"").append(_("GO")).append("\" />");
buf.append("</form>"); buf.append("</form>");
buf.append(_("Statistics gathered during this router's uptime")).append(" ("); buf.append(_("Statistics gathered during this router's uptime")).append(" (");
@ -69,7 +69,7 @@ public class StatsGenerator {
buf.append("<h3><a name=\""); buf.append("<h3><a name=\"");
buf.append(group); buf.append(group);
buf.append("\">"); buf.append("\">");
buf.append(group); buf.append(_(group));
buf.append("</a></h3>"); buf.append("</a></h3>");
buf.append("<ul>"); buf.append("<ul>");
out.write(buf.toString()); out.write(buf.toString());
@ -104,7 +104,7 @@ public class StatsGenerator {
for (int i = 0; i < periods.length; i++) { for (int i = 0; i < periods.length; i++) {
if (periods[i] > uptime) if (periods[i] > uptime)
break; break;
renderPeriod(buf, periods[i], "frequency"); renderPeriod(buf, periods[i], _("frequency"));
Frequency curFreq = freq.getFrequency(periods[i]); Frequency curFreq = freq.getFrequency(periods[i]);
buf.append(" <i>avg per period:</i> ("); buf.append(" <i>avg per period:</i> (");
buf.append(num(curFreq.getAverageEventsPerPeriod())); buf.append(num(curFreq.getAverageEventsPerPeriod()));
@ -138,7 +138,7 @@ public class StatsGenerator {
buf.append("</i><br>"); buf.append("</i><br>");
} }
if (rate.getLifetimeEventCount() <= 0) { if (rate.getLifetimeEventCount() <= 0) {
buf.append("No lifetime events<br>\n"); buf.append(_("No lifetime events")).append("<br>\n");
return; return;
} }
long now = _context.clock().now(); long now = _context.clock().now();
@ -150,9 +150,9 @@ public class StatsGenerator {
if (curRate.getLastCoalesceDate() <= curRate.getCreationDate()) if (curRate.getLastCoalesceDate() <= curRate.getCreationDate())
break; break;
buf.append("<li>"); buf.append("<li>");
renderPeriod(buf, periods[i], "rate"); renderPeriod(buf, periods[i], _("rate"));
if (curRate.getLastEventCount() > 0) { if (curRate.getLastEventCount() > 0) {
buf.append( "<i>avg value:</i> ("); buf.append( "<i>").append(_("avg value")).append(":</i> (");
buf.append(num(curRate.getAverageValue())); buf.append(num(curRate.getAverageValue()));
buf.append(" peak "); buf.append(" peak ");
buf.append(num(curRate.getExtremeAverageValue())); buf.append(num(curRate.getExtremeAverageValue()));
@ -181,21 +181,21 @@ public class StatsGenerator {
buf.append(num(curRate.getExtremeSaturationLimit())); buf.append(num(curRate.getExtremeSaturationLimit()));
buf.append(")"); buf.append(")");
} }
buf.append(" <i>events:</i> "); buf.append(" <i>").append(_("events")).append(":</i> ");
buf.append(curRate.getLastEventCount()); buf.append(curRate.getLastEventCount());
buf.append(" <i>in this period which ended:</i> "); buf.append(" <i>in this period which ended:</i> ");
buf.append(DataHelper.formatDuration(now - curRate.getLastCoalesceDate())); buf.append(DataHelper.formatDuration(now - curRate.getLastCoalesceDate()));
buf.append(" ago "); buf.append(" ago ");
} else { } else {
buf.append(" <i>No events</i> "); buf.append(" <i>").append(_("No events")).append("</i> ");
} }
long numPeriods = curRate.getLifetimePeriods(); long numPeriods = curRate.getLifetimePeriods();
if (numPeriods > 0) { if (numPeriods > 0) {
double avgFrequency = curRate.getLifetimeEventCount() / (double)numPeriods; double avgFrequency = curRate.getLifetimeEventCount() / (double)numPeriods;
double peakFrequency = curRate.getExtremeEventCount(); double peakFrequency = curRate.getExtremeEventCount();
buf.append(" (lifetime average: "); buf.append(" (").append(_("lifetime average")).append(": ");
buf.append(num(avgFrequency)); buf.append(num(avgFrequency));
buf.append(", peak average: "); buf.append(", ").append(_("peak average")).append(": ");
buf.append(curRate.getExtremeEventCount()); buf.append(curRate.getExtremeEventCount());
buf.append(")"); buf.append(")");
} }
@ -213,7 +213,7 @@ public class StatsGenerator {
buf.append("</li>\n"); buf.append("</li>\n");
} }
// Display the strict average // Display the strict average
buf.append("<li><b>lifetime average value:</b> "); buf.append("<li><b>").append(_("lifetime average value")).append(":</b> ");
buf.append(num(rate.getLifetimeAverageValue())); buf.append(num(rate.getLifetimeAverageValue()));
buf.append(" over "); buf.append(" over ");
buf.append(rate.getLifetimeEventCount()); buf.append(rate.getLifetimeEventCount());
@ -240,4 +240,9 @@ public class StatsGenerator {
private String _(String s) { private String _(String s) {
return Messages.getString(s, _context); return Messages.getString(s, _context);
} }
/** translate a string */
private String _(String s, Object o) {
return Messages.getString(s, o, _context);
}
} }

View File

@ -52,5 +52,24 @@ class Dummy {
_("dark"); _("dark");
_("light"); _("light");
_("midnight"); _("midnight");
// stat groups for stats.jsp
_("Bandwidth");
_("BandwidthLimiter");
_("ClientMessages");
_("Encryption");
_("i2cp");
_("I2PTunnel");
_("InNetPool");
_("JobQueue");
_("NetworkDatabase");
_("ntcp");
_("Peers");
_("Router");
_("Stream");
_("Throttle");
_("Transport");
_("Tunnels");
_("udp");
} }
} }