Simplify oldstats.jsp if no events in a stat
This commit is contained in:
@ -72,7 +72,7 @@ public class RateStat {
|
|||||||
if ( (_rates == null) || (_rates.length <= 0) ) return 0;
|
if ( (_rates == null) || (_rates.length <= 0) ) return 0;
|
||||||
return _rates[0].getLifetimeAverageValue();
|
return _rates[0].getLifetimeAverageValue();
|
||||||
}
|
}
|
||||||
public double getLifetimeEventCount() {
|
public long getLifetimeEventCount() {
|
||||||
if ( (_rates == null) || (_rates.length <= 0) ) return 0;
|
if ( (_rates == null) || (_rates.length <= 0) ) return 0;
|
||||||
return _rates[0].getLifetimeEventCount();
|
return _rates[0].getLifetimeEventCount();
|
||||||
}
|
}
|
||||||
|
@ -98,9 +98,12 @@ public class StatsGenerator {
|
|||||||
buf.append("<i>");
|
buf.append("<i>");
|
||||||
buf.append(freq.getDescription());
|
buf.append(freq.getDescription());
|
||||||
buf.append("</i><br />");
|
buf.append("</i><br />");
|
||||||
|
long uptime = _context.router().getUptime();
|
||||||
long periods[] = freq.getPeriods();
|
long periods[] = freq.getPeriods();
|
||||||
Arrays.sort(periods);
|
Arrays.sort(periods);
|
||||||
for (int i = 0; i < periods.length; i++) {
|
for (int i = 0; i < periods.length; i++) {
|
||||||
|
if (periods[i] > uptime)
|
||||||
|
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> (");
|
||||||
@ -128,16 +131,27 @@ public class StatsGenerator {
|
|||||||
|
|
||||||
private void renderRate(String name, StringBuffer buf) {
|
private void renderRate(String name, StringBuffer buf) {
|
||||||
RateStat rate = _context.statManager().getRate(name);
|
RateStat rate = _context.statManager().getRate(name);
|
||||||
|
String d = rate.getDescription();
|
||||||
|
if (! "".equals(d)) {
|
||||||
buf.append("<i>");
|
buf.append("<i>");
|
||||||
buf.append(rate.getDescription());
|
buf.append(d);
|
||||||
buf.append("</i><br />");
|
buf.append("</i><br />");
|
||||||
|
}
|
||||||
|
if (rate.getLifetimeEventCount() <= 0) {
|
||||||
|
buf.append("No lifetime events<br /> <br />");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long now = _context.clock().now();
|
||||||
long periods[] = rate.getPeriods();
|
long periods[] = rate.getPeriods();
|
||||||
Arrays.sort(periods);
|
Arrays.sort(periods);
|
||||||
buf.append("<ul>");
|
buf.append("<ul>");
|
||||||
for (int i = 0; i < periods.length; i++) {
|
for (int i = 0; i < periods.length; i++) {
|
||||||
|
Rate curRate = rate.getRate(periods[i]);
|
||||||
|
if (curRate.getLastCoalesceDate() <= curRate.getCreationDate())
|
||||||
|
break;
|
||||||
buf.append("<li>");
|
buf.append("<li>");
|
||||||
renderPeriod(buf, periods[i], "rate");
|
renderPeriod(buf, periods[i], "rate");
|
||||||
Rate curRate = rate.getRate(periods[i]);
|
if (curRate.getLastEventCount() > 0) {
|
||||||
buf.append( "<i>avg value:</i> (");
|
buf.append( "<i>avg value:</i> (");
|
||||||
buf.append(num(curRate.getAverageValue()));
|
buf.append(num(curRate.getAverageValue()));
|
||||||
buf.append(" peak ");
|
buf.append(" peak ");
|
||||||
@ -167,8 +181,14 @@ public class StatsGenerator {
|
|||||||
buf.append(num(curRate.getExtremeSaturationLimit()));
|
buf.append(num(curRate.getExtremeSaturationLimit()));
|
||||||
buf.append(")");
|
buf.append(")");
|
||||||
}
|
}
|
||||||
buf.append(" <i>events per period:</i> ");
|
buf.append(" <i>events:</i> ");
|
||||||
buf.append(curRate.getLastEventCount());
|
buf.append(curRate.getLastEventCount());
|
||||||
|
buf.append(" <i>in this period which ended:</i> ");
|
||||||
|
buf.append(DataHelper.formatDuration(now - curRate.getLastCoalesceDate()));
|
||||||
|
buf.append(" ago ");
|
||||||
|
} else {
|
||||||
|
buf.append(" <i>No events</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;
|
||||||
@ -191,15 +211,13 @@ public class StatsGenerator {
|
|||||||
buf.append(" in a format <a href=\"http://people.ee.ethz.ch/~oetiker/webtools/rrdtool\">RRDTool</a> understands)");
|
buf.append(" in a format <a href=\"http://people.ee.ethz.ch/~oetiker/webtools/rrdtool\">RRDTool</a> understands)");
|
||||||
}
|
}
|
||||||
buf.append("</li>");
|
buf.append("</li>");
|
||||||
if (i + 1 == periods.length) {
|
}
|
||||||
// last one, so lets display the strict average
|
// Display the strict average
|
||||||
buf.append("<li><b>lifetime average value:</b> ");
|
buf.append("<li><b>lifetime average value:</b> ");
|
||||||
buf.append(num(curRate.getLifetimeAverageValue()));
|
buf.append(num(rate.getLifetimeAverageValue()));
|
||||||
buf.append(" over ");
|
buf.append(" over ");
|
||||||
buf.append(curRate.getLifetimeEventCount());
|
buf.append(rate.getLifetimeEventCount());
|
||||||
buf.append(" events<br /></li>");
|
buf.append(" events<br /></li>");
|
||||||
}
|
|
||||||
}
|
|
||||||
buf.append("</ul>");
|
buf.append("</ul>");
|
||||||
buf.append("<br />");
|
buf.append("<br />");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user