summary bar tweaks
This commit is contained in:
@ -244,7 +244,7 @@ public class SummaryBarRenderer {
|
|||||||
.append(_("Active"))
|
.append(_("Active"))
|
||||||
.append(":</b></td><td align=\"right\">")
|
.append(":</b></td><td align=\"right\">")
|
||||||
.append(_helper.getActivePeers())
|
.append(_helper.getActivePeers())
|
||||||
.append('/')
|
.append(" / ")
|
||||||
.append(_helper.getActiveProfiles())
|
.append(_helper.getActiveProfiles())
|
||||||
.append("</td></tr>\n" +
|
.append("</td></tr>\n" +
|
||||||
|
|
||||||
@ -328,54 +328,48 @@ public class SummaryBarRenderer {
|
|||||||
"<table>\n" +
|
"<table>\n" +
|
||||||
|
|
||||||
"<tr><td align=\"left\"><b>1s:</b></td><td align=\"right\">")
|
"<tr><td align=\"left\"><b>1s:</b></td><td align=\"right\">")
|
||||||
.append(_helper.getInboundSecondKBps())
|
.append(_helper.getSecondKBps())
|
||||||
.append('/')
|
.append("Bps</td></tr>\n");
|
||||||
.append(_helper.getOutboundSecondKBps())
|
|
||||||
.append("K/s</td></tr>\n" +
|
|
||||||
|
|
||||||
"<tr><td align=\"left\"><b>5m:</b></td><td align=\"right\">")
|
if (_context.router().getUptime() > 6*60*1000) {
|
||||||
.append(_helper.getInboundFiveMinuteKBps())
|
buf.append("<tr><td align=\"left\"><b>5m:</b></td><td align=\"right\">")
|
||||||
.append('/')
|
.append(_helper.getFiveMinuteKBps())
|
||||||
.append(_helper.getOutboundFiveMinuteKBps())
|
.append("Bps</td></tr>\n");
|
||||||
.append("K/s</td></tr>\n" +
|
}
|
||||||
|
|
||||||
"<tr><td align=\"left\"><b>")
|
if (_context.router().getUptime() > 2*60*1000) {
|
||||||
|
buf.append("<tr><td align=\"left\"><b>")
|
||||||
.append(_("Total"))
|
.append(_("Total"))
|
||||||
.append(":</b></td><td align=\"right\">")
|
.append(":</b></td><td align=\"right\">")
|
||||||
.append(_helper.getInboundLifetimeKBps())
|
.append(_helper.getLifetimeKBps())
|
||||||
.append('/')
|
.append("Bps</td></tr>\n");
|
||||||
.append(_helper.getOutboundLifetimeKBps())
|
}
|
||||||
.append("K/s</td></tr>\n" +
|
|
||||||
|
|
||||||
"<tr><td align=\"left\"><b>")
|
buf.append("<tr><td align=\"left\"><b>")
|
||||||
.append(_("Used"))
|
.append(_("Used"))
|
||||||
.append(":</b></td><td align=\"right\">")
|
.append(":</b></td><td align=\"right\">")
|
||||||
.append(_helper.getInboundTransferred())
|
.append(_helper.getInboundTransferred())
|
||||||
.append('/')
|
.append(" / ")
|
||||||
.append(_helper.getOutboundTransferred())
|
.append(_helper.getOutboundTransferred())
|
||||||
.append("</td></tr></table>\n" +
|
.append("</td></tr></table>\n" +
|
||||||
|
|
||||||
"<hr><h3><a href=\"/tunnels.jsp\" target=\"_top\" title=\"")
|
"<hr><h3><a href=\"/tunnels.jsp\" target=\"_top\" title=\"")
|
||||||
.append(_("View existing tunnels and tunnel build status"))
|
.append(_("View existing tunnels and tunnel build status"))
|
||||||
.append("\">")
|
.append("\">")
|
||||||
.append(_("Tunnels in/out"))
|
.append(_("Tunnels"))
|
||||||
.append("</a></h3><hr>" +
|
.append("</a></h3><hr>" +
|
||||||
"<table>\n" +
|
"<table>\n" +
|
||||||
|
|
||||||
"<tr><td align=\"left\"><b>")
|
"<tr><td align=\"left\"><b>")
|
||||||
.append(_("Exploratory"))
|
.append(_("Exploratory"))
|
||||||
.append(":</b></td><td align=\"right\">")
|
.append(":</b></td><td align=\"right\">")
|
||||||
.append(_helper.getInboundTunnels())
|
.append(_helper.getInboundTunnels() + _helper.getOutboundTunnels())
|
||||||
.append('/')
|
|
||||||
.append(_helper.getOutboundTunnels())
|
|
||||||
.append("</td></tr>\n" +
|
.append("</td></tr>\n" +
|
||||||
|
|
||||||
"<tr><td align=\"left\"><b>")
|
"<tr><td align=\"left\"><b>")
|
||||||
.append(_("Client"))
|
.append(_("Client"))
|
||||||
.append(":</b></td><td align=\"right\">")
|
.append(":</b></td><td align=\"right\">")
|
||||||
.append(_helper.getInboundClientTunnels())
|
.append(_helper.getInboundClientTunnels() + _helper.getOutboundClientTunnels())
|
||||||
.append('/')
|
|
||||||
.append(_helper.getOutboundClientTunnels())
|
|
||||||
.append("</td></tr>\n" +
|
.append("</td></tr>\n" +
|
||||||
|
|
||||||
"<tr><td align=\"left\"><b>")
|
"<tr><td align=\"left\"><b>")
|
||||||
|
@ -245,96 +245,86 @@ public class SummaryHelper extends HelperBase {
|
|||||||
********/
|
********/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How fast we have been receiving data over the last second (pretty printed
|
* @return "x.xx / y.yy {K|M}"
|
||||||
* string with 2 decimal places representing the KBps)
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public String getInboundSecondKBps() {
|
public String getSecondKBps() {
|
||||||
if (_context == null)
|
if (_context == null)
|
||||||
return "0";
|
return "0 / 0";
|
||||||
double kbps = _context.bandwidthLimiter().getReceiveBps()/1024d;
|
return formatPair(_context.bandwidthLimiter().getReceiveBps(),
|
||||||
DecimalFormat fmt = new DecimalFormat("##0.00");
|
_context.bandwidthLimiter().getSendBps());
|
||||||
return fmt.format(kbps);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* How fast we have been sending data over the last second (pretty printed
|
|
||||||
* string with 2 decimal places representing the KBps)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String getOutboundSecondKBps() {
|
|
||||||
if (_context == null)
|
|
||||||
return "0";
|
|
||||||
double kbps = _context.bandwidthLimiter().getSendBps()/1024d;
|
|
||||||
DecimalFormat fmt = new DecimalFormat("##0.00");
|
|
||||||
return fmt.format(kbps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How fast we have been receiving data over the last 5 minutes (pretty printed
|
* @return "x.xx / y.yy {K|M}"
|
||||||
* string with 2 decimal places representing the KBps)
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public String getInboundFiveMinuteKBps() {
|
public String getFiveMinuteKBps() {
|
||||||
if (_context == null)
|
if (_context == null)
|
||||||
return "0";
|
return "0 / 0";
|
||||||
|
|
||||||
RateStat receiveRate = _context.statManager().getRate("bw.recvRate");
|
RateStat receiveRate = _context.statManager().getRate("bw.recvRate");
|
||||||
if (receiveRate == null) return "0";
|
double in = 0;
|
||||||
Rate rate = receiveRate.getRate(5*60*1000);
|
if (receiveRate != null) {
|
||||||
double kbps = rate.getAverageValue()/1024;
|
Rate r = receiveRate.getRate(5*60*1000);
|
||||||
DecimalFormat fmt = new DecimalFormat("##0.00");
|
if (r != null)
|
||||||
return fmt.format(kbps);
|
in = r.getAverageValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* How fast we have been sending data over the last 5 minutes (pretty printed
|
|
||||||
* string with 2 decimal places representing the KBps)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String getOutboundFiveMinuteKBps() {
|
|
||||||
if (_context == null)
|
|
||||||
return "0";
|
|
||||||
|
|
||||||
RateStat receiveRate = _context.statManager().getRate("bw.sendRate");
|
|
||||||
if (receiveRate == null) return "0";
|
|
||||||
Rate rate = receiveRate.getRate(5*60*1000);
|
|
||||||
double kbps = rate.getAverageValue()/1024;
|
|
||||||
DecimalFormat fmt = new DecimalFormat("##0.00");
|
|
||||||
return fmt.format(kbps);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* How fast we have been receiving data since the router started (pretty printed
|
|
||||||
* string with 2 decimal places representing the KBps)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String getInboundLifetimeKBps() {
|
|
||||||
if (_context == null)
|
|
||||||
return "0";
|
|
||||||
|
|
||||||
RateStat receiveRate = _context.statManager().getRate("bw.recvRate");
|
|
||||||
if (receiveRate == null) return "0";
|
|
||||||
double kbps = receiveRate.getLifetimeAverageValue()/1024;
|
|
||||||
DecimalFormat fmt = new DecimalFormat("##0.00");
|
|
||||||
return fmt.format(kbps);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* How fast we have been sending data since the router started (pretty printed
|
|
||||||
* string with 2 decimal places representing the KBps)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String getOutboundLifetimeKBps() {
|
|
||||||
if (_context == null)
|
|
||||||
return "0";
|
|
||||||
|
|
||||||
RateStat sendRate = _context.statManager().getRate("bw.sendRate");
|
RateStat sendRate = _context.statManager().getRate("bw.sendRate");
|
||||||
if (sendRate == null) return "0";
|
double out = 0;
|
||||||
double kbps = sendRate.getLifetimeAverageValue()/1024;
|
if (sendRate != null) {
|
||||||
DecimalFormat fmt = new DecimalFormat("##0.00");
|
Rate r = sendRate.getRate(5*60*1000);
|
||||||
return fmt.format(kbps);
|
if (r != null)
|
||||||
|
out = r.getAverageValue();
|
||||||
|
}
|
||||||
|
return formatPair(in, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return "x.xx / y.yy {K|M}"
|
||||||
|
*/
|
||||||
|
public String getLifetimeKBps() {
|
||||||
|
if (_context == null)
|
||||||
|
return "0 / 0";
|
||||||
|
|
||||||
|
RateStat receiveRate = _context.statManager().getRate("bw.recvRate");
|
||||||
|
double in;
|
||||||
|
if (receiveRate == null)
|
||||||
|
in = 0;
|
||||||
|
else
|
||||||
|
in = receiveRate.getLifetimeAverageValue();
|
||||||
|
RateStat sendRate = _context.statManager().getRate("bw.sendRate");
|
||||||
|
double out;
|
||||||
|
if (sendRate == null)
|
||||||
|
out = 0;
|
||||||
|
else
|
||||||
|
out = sendRate.getLifetimeAverageValue();
|
||||||
|
return formatPair(in, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return "x.xx / y.yy {K|M}"
|
||||||
|
*/
|
||||||
|
private static String formatPair(double in, double out) {
|
||||||
|
boolean mega = in >= 1024*1024 || out >= 1024*1024;
|
||||||
|
// scale both the same
|
||||||
|
if (mega) {
|
||||||
|
in /= 1024*1024;
|
||||||
|
out /= 1024*1024;
|
||||||
|
} else {
|
||||||
|
in /= 1024;
|
||||||
|
out /= 1024;
|
||||||
|
}
|
||||||
|
// control total width
|
||||||
|
DecimalFormat fmt;
|
||||||
|
if (in >= 1000 || out >= 1000)
|
||||||
|
fmt = new DecimalFormat("#0");
|
||||||
|
else if (in >= 100 || out >= 100)
|
||||||
|
fmt = new DecimalFormat("#0.0");
|
||||||
|
else
|
||||||
|
fmt = new DecimalFormat("#0.00");
|
||||||
|
return fmt.format(in) + " / " + fmt.format(out) +
|
||||||
|
(mega ? 'M' : 'K');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How much data have we received since the router started (pretty printed
|
* How much data have we received since the router started (pretty printed
|
||||||
* string with 2 decimal places and the appropriate units - GB/MB/KB/bytes)
|
* string with 2 decimal places and the appropriate units - GB/MB/KB/bytes)
|
||||||
|
Reference in New Issue
Block a user