ProtobufSystemInfo.Section toProtobuf(MemoryMXBean memoryBean) { ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder(); protobuf.setName(name); addAttributeInMb(protobuf,"Max Memory (MB)", Runtime.getRuntime().maxMemory()); addAttributeInMb(protobuf, "Free Memory (MB)", Runtime.getRuntime().freeMemory()); MemoryUsage heap = memoryBean.getHeapMemoryUsage(); addAttributeInMb(protobuf, "Heap Committed (MB)", heap.getCommitted()); addAttributeInMb(protobuf, "Heap Init (MB)", heap.getInit()); addAttributeInMb(protobuf, "Heap Max (MB)", heap.getMax()); addAttributeInMb(protobuf, "Heap Used (MB)", heap.getUsed()); MemoryUsage nonHeap = memoryBean.getNonHeapMemoryUsage(); addAttributeInMb(protobuf, "Non Heap Committed (MB)", nonHeap.getCommitted()); addAttributeInMb(protobuf, "Non Heap Init (MB)", nonHeap.getInit()); addAttributeInMb(protobuf, "Non Heap Max (MB)", nonHeap.getMax()); addAttributeInMb(protobuf, "Non Heap Used (MB)", nonHeap.getUsed()); OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); setAttribute(protobuf,"System Load Average", format(Locale.ENGLISH, "%.1f%% (last minute)", os.getSystemLoadAverage() * 100.0)); ThreadMXBean thread = ManagementFactory.getThreadMXBean(); setAttribute(protobuf, "Threads", thread.getThreadCount()); return protobuf.build(); }