adamdebreceni commented on a change in pull request #1032: URL: https://github.com/apache/nifi-minifi-cpp/pull/1032#discussion_r600388400
########## File path: libminifi/include/core/state/nodes/DeviceInformation.h ########## @@ -353,119 +355,104 @@ class DeviceInfoNode : public DeviceInformation { std::vector<SerializedResponseNode> serialize() { std::vector<SerializedResponseNode> serialized; + serialized.push_back(serializeIdentifier()); + serialized.push_back(serializeSystemInfo()); + serialized.push_back(serializeNetworkInfo()); + + return serialized; + } + + protected: + SerializedResponseNode serializeIdentifier() { SerializedResponseNode identifier; identifier.name = "identifier"; identifier.value = device_id_; + return identifier; + } - SerializedResponseNode systemInfo; - systemInfo.name = "systemInfo"; - - SerializedResponseNode vcores; - vcores.name = "vCores"; - size_t ncpus = std::thread::hardware_concurrency(); - - vcores.value = ncpus; - - systemInfo.children.push_back(vcores); - - SerializedResponseNode ostype; - ostype.name = "operatingSystem"; - ostype.value = getOperatingSystem(); - - systemInfo.children.push_back(ostype); -#if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) - SerializedResponseNode mem; - mem.name = "physicalMem"; - - uint64_t mema = (size_t) sysconf(_SC_PHYS_PAGES) * (size_t) sysconf(_SC_PAGESIZE); + SerializedResponseNode serializeVCoreInfo() { + SerializedResponseNode v_cores; + v_cores.name = "vCores"; + v_cores.value = std::thread::hardware_concurrency(); + return v_cores; + } - mem.value = mema; + SerializedResponseNode serializeOperatingSystemType() { + SerializedResponseNode os_type; + os_type.name = "operatingSystem"; + os_type.value = getOperatingSystem(); + return os_type; + } - systemInfo.children.push_back(mem); -#endif -#ifndef WIN32 - SerializedResponseNode arch; - arch.name = "machinearch"; + SerializedResponseNode serializeTotalPhysicalMemoryInformation() { + SerializedResponseNode total_physical_memory; + total_physical_memory.name = "physicalMem"; + total_physical_memory.value = (uint64_t)utils::OsUtils::getSystemTotalPhysicalMemory(); + return total_physical_memory; + } - utsname buf; + SerializedResponseNode serializePhysicalMemoryUsageInformation() { + SerializedResponseNode used_physical_memory; + used_physical_memory.name = "memoryUtilization"; + used_physical_memory.value = (uint64_t)utils::OsUtils::getSystemPhysicalMemoryUsage(); Review comment: `static_cast` is preferred (or better yet, `gsl::narrow` if need be) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org