You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/03/24 14:08:51 UTC

[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #1032: MINIFICPP-1504: Add Resource consumption data to heartbeats

szaszm commented on a change in pull request #1032:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1032#discussion_r600511300



##########
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";

Review comment:
       [utilization](https://dictionary.cambridge.org/dictionary/english/utilization):
   > the amount of something available, produced, etc. compared with the total amount that exists or that could be produced
   
   Either we should return a percentage value here or rename this to something like memoryUsage.




-- 
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:
users@infra.apache.org