查找与sys.dm_os_sys_info中的列等效的powershell CIM

问题描述 投票:2回答:1

我有一个正常的SQL Server选择,我从动态管理视图的这两列中收集信息:

SELECT cpu_count, hyperthread_ratio
FROM sys.dm_os_sys_info

我想知道是否有人通过Powershell CIM系统硬件类知道精确的等效项?类似于:

Get-CimInstance -ClassName Win32_Processor

但是我对PC体系结构了解不足,无法知道哪个属性(或基于其他属性的逻辑)直接等于该sql dmv的cpu_count和hyperthread_ratio。

sql-server powershell wmi
1个回答
0
投票

您可以执行以下操作:

$CPUData = @(Get-CIMInstance -Class Win32_Processor | Select NumberOfCores,NumberOfLogicalProcessors)
$CPU_Count = ($CPUData.NumberOfLogicalProcessors | Measure -Sum).Sum
[pscustomobject]@{'CPU_Count' = $CPU_Count
                  'Hyperthread_Ratio' = $CPU_Count/$CPUData.Count
                }

说明:

Get-CIMInstance -Class Win32_Processor返回属性NumberOfLogicalProcessorsNumberOfCores。当这两个属性值不同时,则启用超线程。

[cpu_counthyperthread_ratio仅返回有关逻辑CPU的数据,因此我们只关心计算。

想要的数据在没有计算的情况下就不存在(我可以找到)。 cpu_count是逻辑处理器的总数(NumberOfLogicalProcessors值的总和)。 hyperthread_ratio是逻辑处理器总数除以CPU套接字总数。

顺便说一句,我的测试表明,SQL实例内的处理器亲和力不会影响SQL查询中的计算或数据。

© www.soinside.com 2019 - 2024. All rights reserved.