martinzink commented on a change in pull request #1152:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1152#discussion_r831006768



##########
File path: extensions/procfs/ProcFsSerialization.h
##########
@@ -0,0 +1,164 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+#include <concepts>
+
+#include "CpuStat.h"
+#include "DiskStat.h"
+#include "MemInfo.h"
+#include "NetDev.h"
+#include "ProcessStat.h"
+#include "utils/gsl.h"
+
+namespace org::apache::nifi::minifi::extensions::procfs {
+
+void SerializeCPUStatData(const CpuStatData& cpu_stat_data,
+                          std::invocable<const char(&)[], const uint64_t> auto 
serializer) {
+  serializer("user time", cpu_stat_data.getUser().count());
+  serializer("nice time", cpu_stat_data.getNice().count());
+  serializer("system time", cpu_stat_data.getSystem().count());
+  serializer("idle time", cpu_stat_data.getIdle().count());
+  serializer("io wait time", cpu_stat_data.getIoWait().count());
+  serializer("irq time", cpu_stat_data.getIrq().count());
+  serializer("soft irq time", cpu_stat_data.getSoftIrq().count());
+  serializer("steal time", cpu_stat_data.getSteal().count());
+  serializer("guest time", cpu_stat_data.getGuest().count());
+  serializer("guest nice time", cpu_stat_data.getGuestNice().count());
+}
+
+void SerializeNormalizedCPUStat(const CpuStatData& cpu_stat_data,
+                                std::invocable<const char(&)[], const double> 
auto serializer) {
+  gsl_Expects(cpu_stat_data.getTotal() > 0ms);
+  serializer("user time %", cpu_stat_data.getUser()/cpu_stat_data.getTotal());
+  serializer("nice time %", cpu_stat_data.getNice()/cpu_stat_data.getTotal());
+  serializer("system time %", 
cpu_stat_data.getSystem()/cpu_stat_data.getTotal());
+  serializer("idle time %", cpu_stat_data.getIdle()/cpu_stat_data.getTotal());
+  serializer("io wait time %", 
cpu_stat_data.getIoWait()/cpu_stat_data.getTotal());
+  serializer("irq time %", cpu_stat_data.getIrq()/cpu_stat_data.getTotal());
+  serializer("soft irq %", 
cpu_stat_data.getSoftIrq()/cpu_stat_data.getTotal());
+  serializer("steal time %", 
cpu_stat_data.getSteal()/cpu_stat_data.getTotal());
+  serializer("guest time %", 
cpu_stat_data.getGuest()/cpu_stat_data.getTotal());
+  serializer("guest nice time %", 
cpu_stat_data.getGuestNice()/cpu_stat_data.getTotal());
+}
+
+void SerializeDiskStatData(const DiskStatData& disk_stat_data,
+                           std::invocable<const char(&)[], const uint64_t> 
auto serializer) {
+  serializer("Major Device Number", disk_stat_data.getMajorDeviceNumber());
+  serializer("Minor Device Number", disk_stat_data.getMinorDeviceNumber());
+  serializer("Reads Completed", disk_stat_data.getReadsCompleted());
+  serializer("Reads Merged", disk_stat_data.getReadsMerged());
+  serializer("Sectors Read", disk_stat_data.getSectorsRead());
+  serializer("Writes Completed", disk_stat_data.getWritesCompleted());
+  serializer("Writes Merged", disk_stat_data.getWritesMerged());
+  serializer("Sectors Written", disk_stat_data.getSectorsWritten());
+  serializer("IO-s in progress", disk_stat_data.getIosInProgress());

Review comment:
       agree, changed it in  
https://github.com/apache/nifi-minifi-cpp/pull/1152/commits/84e464c7b9501293616bcae170c4a12a710f7a6d#diff-cb54b002ac8341fabeaff2d9dbbf25274c8a38a9bcb0e9e3a61e67b76f373dbdR75




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to