[sysprof/wip/chergert/sysprof-3] libsysprof: add cpuinfo to capture file when possible



commit 2e93104e84d4bb7d4276423d9283f2734336818f
Author: Christian Hergert <chergert redhat com>
Date:   Mon May 27 18:14:53 2019 -0700

    libsysprof: add cpuinfo to capture file when possible

 src/libsysprof/sysprof-hostinfo-source.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/libsysprof/sysprof-hostinfo-source.c b/src/libsysprof/sysprof-hostinfo-source.c
index 2b39a05..77ad959 100644
--- a/src/libsysprof/sysprof-hostinfo-source.c
+++ b/src/libsysprof/sysprof-hostinfo-source.c
@@ -380,8 +380,22 @@ sysprof_hostinfo_source_prepare (SysprofSource *source)
 {
   SysprofHostinfoSource *self = (SysprofHostinfoSource *)source;
   SysprofCaptureCounter *counters;
+  gint cpuinfo_fd;
 
   g_assert (SYSPROF_IS_HOSTINFO_SOURCE (self));
+  g_assert (self->writer != NULL);
+
+  /* We can generally get this even in containers */
+  if (-1 != (cpuinfo_fd = g_open ("/proc/cpuinfo", O_RDONLY)))
+    {
+      sysprof_capture_writer_add_file_fd (self->writer,
+                                          SYSPROF_CAPTURE_CURRENT_TIME,
+                                          -1,
+                                          -1,
+                                          "/proc/cpuinfo",
+                                          cpuinfo_fd);
+      close (cpuinfo_fd);
+    }
 
   self->stat_fd = open ("/proc/stat", O_RDONLY);
   self->n_cpu = g_get_num_processors ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]