]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: include CPU info 889/head
authorLoic Dachary <loic@dachary.org>
Tue, 3 Dec 2013 14:39:36 +0000 (15:39 +0100)
committerLoic Dachary <loic@dachary.org>
Tue, 3 Dec 2013 14:39:36 +0000 (15:39 +0100)
It will be handy when trying to figure out CPU bound problems / benchmarks.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/osd/OSD.cc

index dce9c299c8bfab2067f5ccdd82ac90bf80e6a8b8..e601d51e7b72669fb50a7abc5f4add01e43608b7 100644 (file)
@@ -3616,6 +3616,30 @@ void OSD::_collect_metadata(map<string,string> *pm)
     fclose(f);
   }
 
+  // processor
+  f = fopen("/proc/cpuinfo", "r");
+  if (f) {
+    char buf[100];
+    while (!feof(f)) {
+      char *line = fgets(buf, sizeof(buf), f);
+      if (!line)
+       break;
+      if (strncmp(line, "model name", 10) == 0) {
+       char *c = strchr(buf, ':');
+       c++;
+       while (*c == ' ')
+         ++c;
+       char *nl = c;
+       while (*nl != '\n')
+         ++nl;
+       *nl = '\0';
+       (*pm)["cpu"] = c;
+       break;
+      }
+    }
+    fclose(f);
+  }
+
   // distro info
   f = fopen("/etc/lsb-release", "r");
   if (f) {