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.
cpu_percent
:1-或多个CPU returns相同:cpu_percent
值
的一维列表
percpu=False
returnsint
如2.3
percpu=True
returnslist[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_temparatures
returnsdict[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_fans
returnsdict[str,list[namedtuple]
如
{'asus': [sfan(label='cpu_fan', current=3200)]}
我需要知道以下 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.
的一维列表cpu_percent
:1-或多个CPU returns相同:cpu_percent
值percpu=False
returnsint
如2.3
percpu=True
returnslist[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]
- for 1CPU-4cores-8threads
sensor_temparatures
returnsdict[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_fans
returnsdict[str,list[namedtuple]
如{'asus': [sfan(label='cpu_fan', current=3200)]}