Page 1 of 1

Help needed: Find cpu type from python

Posted: January 24th, 2017, 2:16 pm
by sander
Hi,

On Linux, SABnzbd finds and reports the CPU on which SAB is running. That's handy in case of performance issues.

I've now extended that to Windows en MacOS (see https://github.com/sanderjo/getcpu/blob ... /getcpu.py). It's lacking on FreeBSD because I have no access to FreeBSD.

Could you help?

First:
What is the output of:

Code: Select all

python -c "import platform ; print platform.system()"
Second:
What is a handy command to find the CPU? Suggestions I found on the web:

Code: Select all

sysctl hw.model

Code: Select all

dmesg | grep -i cpu
What is the result of those command on FreeBSD? Do you need to be root?

Re: Help needed: Find cpu type from python

Posted: January 24th, 2017, 4:02 pm
by jcfp
Can't help with your actual questions, but the freebsd website does have virtual machine images available at https://www.freebsd.org/where.html that may be useful to setup a test environment.

Re: Help needed: Find cpu type from python

Posted: January 24th, 2017, 5:32 pm
by sander
OK ... installing VirtualBox right now...

Hopefully no need for ZFS and very large free space ...

Re: Help needed: Find cpu type from python

Posted: January 25th, 2017, 3:02 am
by sander
platform.system() tells "FreeBSD"

"dmesg | grep CPU:" tells the CPU

"sysctl hw.model" tells the CPU too. No root needed, so that's good.


To install python aka python2:

Code: Select all

pkg install python2

Code: Select all

$ /usr/local/bin/python2  -c "import platform ; print platform.system()"
FreeBSD

Code: Select all

$ sysctl hw.model
hw.model: Intel(R) Core(TM) i3 CPU       M 370  @ 2.40GHz

Code: Select all

$ dmesg | grep CPU:
CPU: Intel(R) Core(TM) i3 CPU       M 370  @ 2.40GHz (2394.82-MHz K8-class CPU)
Code now working:

Code: Select all

$ /usr/local/bin/python2 getcpu.py
Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz