buf.append(", ").append(stats.totalMessageBytes); buf.append(", ").append(stats.totalMessageCount);
buf.append(", ").append(stats.totalSentMessageBytes); buf.append(", ").append(stats.totalSentMessageCount);
  private String getCSV() {    StringBuffer buf = new StringBuffer();    buf.append(agentId.getAddress());    buf.append(", ").append(System.currentTimeMillis());    if (protoRegistryService != null) {      buf.append(", ").append(protoRegistryService.getCachedPrototypeCount());      buf.append(", ").append(protoRegistryService.getPropertyProviderCount());      buf.append(", ").append(protoRegistryService.getPrototypeProviderCount());    } else {      buf.append(", 0, 0, 0");    }    if (bbMetricsService != null) {      buf.append(", ").append(bbMetricsService.getBlackboardCount(Asset.class));      buf.append(", ").append(bbMetricsService.getBlackboardCount(PlanElement.class));      buf.append(", ").append(bbMetricsService.getBlackboardCount(Task.class));      buf.append(", ").append(bbMetricsService.getBlackboardCount());    } else {      buf.append(", 0, 0, 0, 0");    }    if (nodeMetricsService != null) {      buf.append(", ").append(nodeMetricsService.getActiveThreadCount());      buf.append(", ").append(nodeMetricsService.getFreeMemory());      buf.append(", ").append(nodeMetricsService.getTotalMemory());    } else {      buf.append(", 0, 0, 0");    }    buf.append(", ").append(getMetric(cpuPath, 0.0));    buf.append(", ").append(getMetric(toMsgPath, 0.0));    buf.append(", ").append(getMetric(fromMsgPath, 0.0));    if (messageStatsService != null) {      MessageStatistics.Statistics stats =         messageStatsService.getMessageStatistics(false);      buf.append(", ").append(stats.averageMessageQueueLength);      buf.append(", ").append(stats.totalMessageBytes);      buf.append(", ").append(stats.totalMessageCount);      long[] h = stats.histogram;      for (int i = 0; i < MessageStatistics.NBINS; i++) {        long hi = (i < h.length ? h[i] : 0l);        buf.append(", ").append(hi);      }    } else {      buf.append(", 0, 0, 0");      for (int i = 0; i < MessageStatistics.NBINS; i++) {        buf.append(", 0");      }    }    if (myMessageWatcher != null) {      buf.append(", ").append(myMessageWatcher.directivesIn);      buf.append(", ").append(myMessageWatcher.directivesOut);      buf.append(", ").append(myMessageWatcher.notificationsIn);      buf.append(", ").append(myMessageWatcher.notificationsOut);    } else {      buf.append(", 0, 0, 0, 0");    }    return buf.toString();  }