Help needed: Find cpu type from python

Support for the freeBSD package, created by dbrooks
Post Reply
User avatar
sander
Release Testers
Release Testers
Posts: 6049
Joined: January 22nd, 2008, 2:22 pm

Help needed: Find cpu type from python

Post by sander » January 24th, 2017, 2:16 pm

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?

User avatar
jcfp
Release Testers
Release Testers
Posts: 849
Joined: February 7th, 2008, 12:45 pm

Re: Help needed: Find cpu type from python

Post by jcfp » January 24th, 2017, 4:02 pm

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.

User avatar
sander
Release Testers
Release Testers
Posts: 6049
Joined: January 22nd, 2008, 2:22 pm

Re: Help needed: Find cpu type from python

Post by sander » January 24th, 2017, 5:32 pm

OK ... installing VirtualBox right now...

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

User avatar
sander
Release Testers
Release Testers
Posts: 6049
Joined: January 22nd, 2008, 2:22 pm

Re: Help needed: Find cpu type from python

Post by sander » January 25th, 2017, 3:02 am

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

Post Reply