title: Find MaxNumberOfProcesses in Windows without WMI
body: <p>Our monitoring solution currently uses WMI for a few of it's metrics, however when under load WMI performs terribly and often fails to return in time, causing a large number of false alerts of various things being offline or missing metrics.</p>
  <p>Replacing WMI queries with calls to windows functions found in psapi.h, sysinfoapi.h and others has resolved a majority of these and return about 100x faster, however I am unable to find a way to get the equivalent value of WMI query Win32_OperatingSystem.MaxNumberOfProcesses</p>
  <p>The definition from the windows documentation <a href="https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-operatingsystem" rel="nofollow noreferrer">here</a> states:</p>
  <pre><code>MaxNumberOfProcesses
  
  Data type: uint32
  
  Access type: Read-only
  
  Qualifiers: MappingStrings (&quot;MIB.IETF|HOST-RESOURCES-MIB.hrSystemMaxProcesses&quot;)
  
  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.
  </code></pre>
  <p>I've tested this value on about 10 different machines, each with differing numbers of CPU and RAM, all of which have returned the above default value of 4294967295 (0xFFFFFFFF). Am I to assume that Windows is actually just sending back this value directly, or should I be returning the value of ULONG_MAX, or is there another way of finding what this value should be?</p>
  <p>I tried figure out a way to access the HOST MIB for windows but can't find any details on it other than using some external tool, not directly via code.</p>
  <p>I'm currently programming this in the GO language, utilizing C libraries.</p>
  <p>If anyone can provide insight into how to retrieve this value without using WMI that would be greatly appreciated.</p>