getting cpu info w/o parsing /var/run/dmesg.boot

Michael Neumann mneumann at ntecs.de
Fri Oct 9 03:40:28 PDT 2015



On 10/09/15 12:38, Hleb Valoshka wrote:
> Hi all.
>
> I want to get info about cpu without parsing /var/run/dmesg.boot, is
> it possible?
>
> I'm porting ohai (https://github.com/chef/ohai/pull/626/files#r41601905).

You can use sysctl to extract information, e.g.:

sysctl hw.cpu_topology.tree
hw.cpu_topology.tree:
\-PACKAGE MEMBERS: cpus(0-7)
   \-CHIP ID 0: cpus(0-7)
     |-CORE ID 0: cpus(0, 4)
     | |-THREAD ID 0: cpus(0)
     | \-THREAD ID 1: cpus(4)
     |-CORE ID 1: cpus(1, 5)
     | |-THREAD ID 0: cpus(1)
     | \-THREAD ID 1: cpus(5)
     |-CORE ID 2: cpus(2, 6)
     | |-THREAD ID 0: cpus(2)
     | \-THREAD ID 1: cpus(6)
     \-CORE ID 3: cpus(3, 7)
       |-THREAD ID 0: cpus(3)
       \-THREAD ID 1: cpus(7)

What information you are looking for exactly?

Regards,

   Michael



More information about the Users mailing list