Python 模块命令输出请求(Linux)

A Python Module Command Output Request (on Linux)

我需要知道以下 Python psutil 模块命令输出如何用于多个 CPU(CPU 套接字)计算机:

import psutil
print(psutil.cpu_percent(interval=0.3, percpu=True))
print(psutil.sensors_temperatures(fahrenheit=False))
print(psutil.sensors_fans())

注意: Python 包 psutil 应该被安装。 注意 2: 最后两个命令在 Windows 上不可用。他们应该 运行 在 Linux.

来自psutil documentaion

  • cpu_percent:1-或多个CPU returns相同:cpu_percent

    的一维列表
    • percpu=Falsereturnsint2.3

    • percpu=Truereturnslist[int]

      • for 1CPU-4cores-8threads [23.8, 5.0, 10.0, 5.0, 15.0, 5.0, 15.0, 23.8]
      • 4CPU-4x4cores-4x8threads [23.8, 5.0, 10.0, 5.0, 15.0, 5.0, 15.0, 23.8,23.8, 5.0, 10.0, 5.0, 15.0, 5.0, 15.0, 23.8,23.8, 5.0, 10.0, 5.0, 15.0, 5.0, 15.0, 23.8,23.8, 5.0, 10.0, 5.0, 15.0, 5.0, 15.0, 23.8]
  • sensor_temparaturesreturnsdict[str,list[namedtuple]

    {'acpitz'  : [shwtemp(label='', current=47.0, high=103.0, critical=103.0)],
     'asus'    : [shwtemp(label='', current=47.0, high=None, critical=None)],
     'coretemp': [shwtemp(label='Physical id 0', current=52.0, high=100.0, critical=100.0),
                 shwtemp(label='Core 0', current=45.0, high=100.0, critical=100.0),
                 shwtemp(label='Core 1', current=52.0, high=100.0, critical=100.0),
                 shwtemp(label='Core 2', current=45.0, high=100.0, critical=100.0),
                 shwtemp(label='Core 3', current=47.0, high=100.0, critical=100.0)]}
    
  • sensors_fansreturnsdict[str,list[namedtuple]

    {'asus': [sfan(label='cpu_fan', current=3200)]}