在Windows如何用python运行Linux的dmidecode命令
请问在Windows中如何用python运行Linux的dmidecode命令 除非windows提供类似的函数或可执行文件否则,怎么可能实现 wp231957 发表于 2022-10-21 12:29
除非windows提供类似的函数或可执行文件
否则,怎么可能实现
那请问python代码怎么实现在windows、Linux系统上查询系统一共有可支持多少个CPU及Memory插槽,以及目前已经插了几个CPU,几根Memory,分别是哪几根(或者是在哪个插槽插的),我只知道Linux系统下dmidecode可以实现 怪兽同学 发表于 2022-10-21 13:02
那请问python代码怎么实现在windows、Linux系统上查询系统一共有可支持多少个CPU及Memory插槽,以及目 ...
那就把这个代码下载下来,研究研究他是怎么写的 人造人 发表于 2022-10-21 13:08
那就把这个代码下载下来,研究研究他是怎么写的
我下载了,7000行代码。。。。 怪兽同学 发表于 2022-10-21 15:09
我下载了,7000行代码。。。。
嗯,研究研究他是怎么做的 psutil suchocolate 发表于 2022-10-22 09:31
psutil
这个我也看了,好像也不行 怪兽同学 发表于 2022-10-24 07:57
这个我也看了,好像也不行
把你尝试了psutil的代码发出来 怪兽同学 发表于 2022-10-21 15:09
我下载了,7000行代码。。。。
最近在研究smbios,smbios里面有你想要的东西
7.17 Physical Memory Array (Type 16)
Handle 0x003D, DMI type 16, 23 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: None
Maximum Capacity: 64 GB
Error Information Handle: Not Provided
Number Of Devices: 4
这里面的 Number Of Devices 字段写了一共有多少个插槽,我这台电脑有4个
然后
7.18 Memory Device (Type 17)
结构会出现4次
如果你安装了内存条,这里显示内存条的一些信息,如果没有安装内存条,这里显示 Unknown
Size 字段是 No Module Installed
这是原话
Size of the memory device If the value is 0, no memory device is installed in the socket; if the size is unknown, the field value is FFFFh. If the size is 32 GB-1 MB or greater, the field value is 7FFFh and the actual size is stored in the Extended Size field.
The granularity in which the value is specified depends on the setting of the most-significant bit (bit 15). If the bit is 0, the value is specified in megabyte units; if the bit is 1, the value is specified in kilobyte units. For example, the value 8100h identifies a 256 KB memory device and 0100h identifies a 256 MB memory device.
内存设备的大小 如果值为0,则插槽中未安装内存设备
这样你就可以知道一共有几个内存插槽,插了几根内存条
cpu插槽应该也是这样的操作,不过我这边只有一个cpu插槽,没办法帮你验证
Handle 0x003D, DMI type 16, 23 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: None
Maximum Capacity: 64 GB
Error Information Handle: Not Provided
Number Of Devices: 4
Handle 0x003E, DMI type 17, 40 bytes
Memory Device
Array Handle: 0x003D
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 8 GB
Form Factor: DIMM
Set: None
Locator: ChannelA-DIMM0
Bank Locator: BANK 0
Type: DDR4
Type Detail: Synchronous
Speed: 2133 MT/s
Manufacturer: 8313
Serial Number: 00000000
Asset Tag: 9876543210
Part Number: CL16-16-16 D4-2400
Rank: 2
Configured Memory Speed: 2133 MT/s
Minimum Voltage: 1.2 V
Maximum Voltage: 1.2 V
Configured Voltage: 1.2 V
Handle 0x003F, DMI type 17, 40 bytes
Memory Device
Array Handle: 0x003D
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 8 GB
Form Factor: DIMM
Set: None
Locator: ChannelA-DIMM1
Bank Locator: BANK 1
Type: DDR4
Type Detail: Synchronous
Speed: 2133 MT/s
Manufacturer: 8313
Serial Number: 00000000
Asset Tag: 9876543210
Part Number: CL16-16-16 D4-2400
Rank: 2
Configured Memory Speed: 2133 MT/s
Minimum Voltage: 1.2 V
Maximum Voltage: 1.2 V
Configured Voltage: 1.2 V
Handle 0x0040, DMI type 17, 40 bytes
Memory Device
Array Handle: 0x003D
Error Information Handle: Not Provided
Total Width: Unknown
Data Width: Unknown
Size: No Module Installed
Form Factor: Unknown
Set: None
Locator: ChannelB-DIMM0
Bank Locator: BANK 2
Type: Unknown
Type Detail: None
Handle 0x0041, DMI type 17, 40 bytes
Memory Device
Array Handle: 0x003D
Error Information Handle: Not Provided
Total Width: Unknown
Data Width: Unknown
Size: No Module Installed
Form Factor: Unknown
Set: None
Locator: ChannelB-DIMM1
Bank Locator: BANK 3
Type: Unknown
Type Detail: None
参考:https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf Windows应该是用 wmic 命令(cmd),如 wmic memorychip 或wmic memorychip list brief
或PowerShell命令:Get-WmiObject ,如 Get-WmiObject -Class Win32_PhysicalMemory
可以查查:Windows 获取硬件信息
如果可以,那剩下的就是Python中如何调用这些系统命令的问题了。
页:
[1]