Thursday, November 29, 2012

Getting CPU info from the command line in OSX

Ever wonder what processor your mac is running and what features it has? Apple usually doesn't disclose the processor model name. Rather, they simply tell you it is a quad core i7 or dual core i5.


For example, does it support VT-d/VT-x? Well, in the command line, you can find out what processor it has and look it up on Intel's ark site.


 For example, if you had an i7 3770k, you could go and get the full specs at by googling "ark 3770k" which gives you a link to the specs at : http://ark.intel.com/products/65523

In linux you can cat /proc/cpuinfo.

Well, I will show you the OSX equivalents. Instead of cpuinfo, we have sysctl To get the model name
in Linux In linux:
 grep "model name" /proc/cpuinfo  

In OSX, it is:
 sysctl -n machdep.cpu.brand_string  


To get full CPU info Linux:
 cat /proc/cpuinfo  
OSX:
 sysctl -a | grep machdep.cpu  


Want to know the core count and threads, you do another pipe grep. In OSX:

 sysctl -a | grep machdep.cpu | grep core_count  
 sysctl -a | grep machdep.cpu | grep thread_count  


Here is a full example:


5 comments:

  1. semi-related question: we use Nagios to monitor some hosts, particularly for the presence of active NFS mounts -- on Linux, the plugin refers to /proc and /etc/mtab. I'm stumped about the "equivalent" on OSX. Any pointers?

    ReplyDelete
    Replies
    1. I've only use nagios on Linux. never on OSX. have you tried nagios/plugins/check_disk -w 15% -c 10% -p /a_mount_point . Just check for the existing of the path. OSX also has a command, showmount you can look into

      Delete
  2. We want to make sure the system itself sees the mount and that it's NFS-functional. Seems OSX has to do things so differently (ie: no /proc or /etc/mtab to refer to). I even asked Apple Support and they were clueless. I'm awaiting an Apple Developer Subscription to be activated so I have access to those resources. Thanks :-)

    ReplyDelete
  3. Why sysctl -a | grep machdep.cpu | grep core_count

    Why not simply sysctl machdep.cpu.core_count

    ReplyDelete