[FACT-959] Incorrect processor counts on Windows Created: 2015/04/19  Updated: 2016/03/16  Resolved: 2016/01/05

Status: Closed
Project: Facter
Component/s: Windows
Affects Version/s: FACT 2.4.3
Fix Version/s: FACT 2.4.5

Type: Bug Priority: Normal
Reporter: Ben Bodenmiller Assignee: John Duarte
Resolution: Fixed Votes: 2
Labels: windows
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Running Ruby 2.0.0p353 bundled with Vagrant 1.7.2 on Windows 8.1


Template:
Story Points: 1
Sprint: Client 2016-01-13
Release Notes: Bug Fix
Release Notes Summary: An issue with reporting the number of physical processors as the number of logical processors has been fixed.

 Description   

When running `Facter.value('processors')['count']` and `Facter.value('processors')['physicalcount']` both are returning 1. Per the task manager and WMI my machine has 1 socket CPU, 2 cores & 4 logical processors.



 Comments   
Comment by Christopher Pisano [ 2015/06/04 ]

I am seeing this behavior (Facter only showing the CPU socket count) on all of my windows servers running Facter version 2.x. It is in a VMware environment. It seems that Facter version 1.x shows the correct processor count.

Comment by Jasmine Nouriel [ 2015/11/22 ]

We are also experiencing this behavior. I found the bug and opened a pull request in Github:
https://github.com/puppetlabs/facter/pull/1229

The issue is with the proc.respond_to?(:NumberOfLogicalProcessors) (facter/processors/os.rb line 115) which always returns false since the NumberOfLogicalProcessors is not a regular method but an OLE method. Therefore it should use the ole_respond_to? method (WIN32OLE class):

irb(main):013:0> Facter::Util::WMI.execquery("select * from Win32_Processor").each do |proc|
irb(main):014:1* puts proc.NumberOfLogicalProcessors
irb(main):015:1> puts proc.respond_to?(:NumberOfLogicalProcessors)
irb(main):016:1> end
2
false
2
false
2
false
2
false

irb(main):018:0* Facter::Util::WMI.execquery("select * from Win32_Processor").each do |proc|
irb(main):019:1* puts proc.NumberOfLogicalProcessors
irb(main):020:1> puts proc.ole_respond_to?(:NumberOfLogicalProcessors)
irb(main):021:1> end
2
true
2
true
2
true
2

Comment by John Duarte [ 2016/01/05 ]

Validated on Windows 2012r2 using facter} at sha {{ba8b3d08499ffcc09380acafa4687bcb350104e7.

Generated at Sat Dec 07 20:52:05 PST 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.