pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

actor-framework: add NetBSD process metrics



Module Name:	pkgsrc-wip
Committed By:	Niclas Rosenvik <nros%pkgsrc.org@localhost>
Pushed By:	nros
Date:		Sun Jan 9 11:00:09 2022 +0100
Changeset:	7e62cf93a37fdaafd3916ef842fe271c1d0e9c16

Modified Files:
	actor-framework/distinfo
	actor-framework/patches/patch-libcaf__core_src_telemetry_importer_process.cpp

Log Message:
actor-framework: add NetBSD process metrics

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=7e62cf93a37fdaafd3916ef842fe271c1d0e9c16

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 actor-framework/distinfo                           |  2 +-
 ...libcaf__core_src_telemetry_importer_process.cpp | 48 +++++++++++++++++++++-
 2 files changed, 47 insertions(+), 3 deletions(-)

diffs:
diff --git a/actor-framework/distinfo b/actor-framework/distinfo
index 4774a95895..c1289da1a9 100644
--- a/actor-framework/distinfo
+++ b/actor-framework/distinfo
@@ -10,5 +10,5 @@ SHA1 (patch-libcaf__core_src_detail_get__mac__addresses.cpp) = 509e8081f66cebe93
 SHA1 (patch-libcaf__core_src_detail_get__root__uuid.cpp) = ba158be8761dfe0dc5705de48c885e4cc9739743
 SHA1 (patch-libcaf__core_src_detail_pretty__type__name.cpp) = 922423499220ba8481da6076877fb755ab49c569
 SHA1 (patch-libcaf__core_src_detail_set__thread__name.cpp) = fb3cfefb1eccbf77ccf65173f1cfeb1e71b2e875
-SHA1 (patch-libcaf__core_src_telemetry_importer_process.cpp) = 729b9574cba607f9c05558150a780701ea75e7ba
+SHA1 (patch-libcaf__core_src_telemetry_importer_process.cpp) = 00215e17c6536d7e90abd54871fbbeb9842955bd
 SHA1 (patch-libcaf__io_CMakeLists.txt) = 327649d0fef862e75a5367d38e1baf769923c9f0
diff --git a/actor-framework/patches/patch-libcaf__core_src_telemetry_importer_process.cpp b/actor-framework/patches/patch-libcaf__core_src_telemetry_importer_process.cpp
index 797ce5e85e..9a2caa49d1 100644
--- a/actor-framework/patches/patch-libcaf__core_src_telemetry_importer_process.cpp
+++ b/actor-framework/patches/patch-libcaf__core_src_telemetry_importer_process.cpp
@@ -9,11 +9,11 @@ $NetBSD$
  // -- detect supported platforms -----------------------------------------------
  
 -#if defined(CAF_MACOS) || defined(CAF_LINUX)
-+#if defined(CAF_MACOS) || defined(CAF_LINUX) || defined(CAF_SOLARIS)
++#if defined(CAF_MACOS) || defined(CAF_LINUX) || defined(CAF_SOLARIS) || defined(CAF_NETBSD)
  #  define CAF_HAS_PROCESS_METRICS
  #endif
  
-@@ -212,6 +212,48 @@ sys_stats read_sys_stats() {
+@@ -212,6 +212,92 @@ sys_stats read_sys_stats() {
  
  #endif // CAF_LINUX
  
@@ -58,6 +58,50 @@ $NetBSD$
 +} // namespace 
 +
 +#endif // CAF_SOLARIS
++
++#if defined(CAF_NETBSD)
++
++#include <sys/sysctl.h>
++#include <unistd.h>
++
++namespace {
++
++sys_stats read_sys_stats() {
++  sys_stats result{0, 0, 0};
++  int mib[6];
++  struct kinfo_proc2 kip2;
++  size_t kip2_size = sizeof(kip2);
++
++  mib[0] = CTL_KERN;
++  mib[1] = KERN_PROC2;
++  mib[2] = KERN_PROC_PID;
++  mib[3] = getpid();
++  mib[4] = kip2_size;
++  mib[5] = 1;
++
++  long page_size = sysconf(_SC_PAGE_SIZE);
++  if (page_size == -1) {
++    CAF_LOG_ERROR("getting _SC_PAGE_SIZE from sysconf failed in read_sys_stats");
++    return result;
++  }
++
++
++  if (sysctl(mib, 6, &kip2, &kip2_size, NULL, (size_t)0)) {
++    CAF_LOG_ERROR("sysctl failed in read_sys_stats");
++    return result;
++  }
++
++  result.rss = static_cast<int64_t>(kip2.p_vm_rssize) * page_size;
++  result.vms = static_cast<int64_t>(kip2.p_vm_vsize) * page_size;
++  result.cpu_time = kip2.p_rtime_sec;
++  result.cpu_time += static_cast<double>(kip2.p_rtime_usec) / 1000000;
++
++  return result;
++}
++
++} // namepace
++
++#endif // CAF_NETBSD
 +
  namespace caf::telemetry::importer {
  


Home | Main Index | Thread Index | Old Index