gpt4 book ai didi

c - 在没有 WMI 的 Windows 中查找 MaxNumberOfProcesses

转载 作者:行者123 更新时间:2023-12-03 10:07:34 24 4
gpt4 key购买 nike

我们的监控解决方案目前将 WMI 用于它的一些指标,但是当负载不足时,WMI 性能非常糟糕并且经常无法及时返回,从而导致大量关于各种事物脱机或缺少指标的错误警报。
将 WMI 查询替换为调用 psapi.h、sysinfoapi.h 等中的 Windows 函数已解决了其中的大部分问题,并且返回速度提高了大约 100 倍,但是我无法找到一种方法来获得 WMI 查询 Win32_OperatingSystem.MaxNumberOfProcesses 的等效值
Windows 文档中的定义 here状态:

MaxNumberOfProcesses

Data type: uint32

Access type: Read-only

Qualifiers: MappingStrings ("MIB.IETF|HOST-RESOURCES-MIB.hrSystemMaxProcesses")

Maximum number of process contexts the operating system can support.
The default value set by the provider is 4294967295 (0xFFFFFFFF). If there is no fixed maximum, the value should be 0 (zero). On systems that have a fixed maximum, this object can help diagnose failures that occur when the maximum is reached—if unknown, enter 4294967295 (0xFFFFFFFF).

This property is inherited from CIM_OperatingSystem.
我已经在大约 10 台不同的机器上测试了这个值,每台机器都有不同数量的 CPU 和 RAM,所有这些机器都返回了上述默认值 4294967295 (0xFFFFFFFF)。我是否应该假设 Windows 实际上只是直接发回这个值,或者我应该返回 ULONG_MAX 的值,还是有另一种方法可以找到这个值应该是什么?
我尝试了一种访问 Windows 主机 MIB 的方法,但除了使用一些外部工具而不是直接通过代码之外,找不到任何详细信息。
我目前正在使用 C 库在 GO 语言中对此进行编程。
如果有人可以提供有关如何在不使用 WMI 的情况下检索此值的见解,那将不胜感激。

最佳答案

您可以使用 CIM_OperatingSystem class CIM(通用信息模型)https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/cim-operatingsystem

[Abstract, UUID("{8502C565-5FBB-11D2-AAC1-006008C78BC7}"), AMENDMENT]
class CIM_OperatingSystem : CIM_LogicalElement
{
string Caption;
string CreationClassName;
string CSCreationClassName;
string CSName;
sint16 CurrentTimeZone;
string Description;
boolean Distributed;
uint64 FreePhysicalMemory;
uint64 FreeSpaceInPagingFiles;
uint64 FreeVirtualMemory;
datetime InstallDate;
datetime LastBootUpTime;
datetime LocalDateTime;
uint32 MaxNumberOfProcesses; <----------------------------------------
uint64 MaxProcessMemorySize;
string Name;
uint32 NumberOfLicensedUsers;
uint32 NumberOfProcesses;
uint32 NumberOfUsers;
uint16 OSType;
string OtherTypeDescription;
uint64 SizeStoredInPagingFiles;
string Status;
uint64 TotalSwapSpaceSize;
uint64 TotalVirtualMemorySize;
uint64 TotalVisibleMemorySize;
string Version;
};

The DMTF (Distributed Management Task Force) CIM (Common InformationModel) classes are the parent classes upon which WMI classes arebuilt. WMI currently supports only the CIM 2.x version schemas.


如果一台机器上的进程数不受限制 MaxNumberOfProcesses0

Maximum number of process contexts the OperatingSystem can support. If there is no fixed maximum, the value should be 0. On systems that have a fixed maximum, this object can help diagnose failures that occur when the maximum is reached.


关于 WMI之间的关系和 CIMhttps://www.red-gate.com/simple-talk/sysadmin/powershell/powershell-day-to-day-admin-tasks-wmi,-cim-and-pswa/
公共(public)信息模型

Since the third version of PowerShell, a new module has beenintroduced in Windows Server 2012 and Windows 8 that is calledCIMCmdlets. It has been added so as to replace the legacy WMI cmdlets.If you regularly use WMI, then you will not be lost when moving to thenew cmdlets as there are lots of similarities.

The first command to use is Get-CimInstance:

PS> Get-CimInstance -Class Win32_Process

You will notice that it is possible to make requests on the WMIclasses. To give a simple summary:

Get-WmiObject is replaced by Get-CimInstance
Get-WmiObject -list is replaced by Get-CimClass

Let’s see in detail the new functionality presented by CIM


命名空间: https://wutils.com/wmi/root/cimv2/properties/maxnumberofprocesses.html

关于c - 在没有 WMI 的 Windows 中查找 MaxNumberOfProcesses,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65675830/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com