/**
* Gather performance data for all connections in a broker,
* compute dervied numbers, and return in one convenience class
*/
public synchronized MetricData getMetrics() {
MetricData md = new MetricData();
Runtime rt = Runtime.getRuntime();
long currentTime = System.currentTimeMillis();
// long elapsedSecs = (currentTime - lastSampleTime) / 1000;
float elapsedSecs = (currentTime - lastSampleTime) / (float)1000;
MetricCounters totals = getMetricCounters(null);
// Copy values into MetricData
md.timestamp = currentTime;
md.totalMemory = rt.totalMemory();
md.freeMemory = rt.freeMemory();
md.nConnections = totals.nConnections;
// Totals are straight copies
md.setTotals(totals);
// Rates must be computed
md.rates.messagesIn = (long)
((totals.messagesIn - lastSample.messagesIn) / elapsedSecs);
md.rates.messageBytesIn = (long)