Skip to content

Commit

Permalink
Add logical processors to custom field
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbarclay committed Jul 4, 2024
1 parent b9c394b commit b8fe02e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions unix/src/machine_stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,12 @@ def storage_used_gb(facts):


def cpu_count(facts):
"""Return the number of CPUs"""
return max(
[
int(facts.get("ansible_processor_count", 0)),
int(facts.get("ansible_processor_vcpus", 0)),
]
)
"""Return the number of CPU cores"""
return int(facts.get("ansible_processor_count", 0))

def cpu_logical_processors(facts):
"""Return the number of CPU logical processors."""
return int(facts.get("ansible_processor_vcpus", 0))


def cpu_name(proc):
Expand Down Expand Up @@ -222,6 +221,9 @@ def v2_runner_on_ok(self, result):
"storage_allocated_gb": storage_allocated_gb(facts),
"storage_used_gb": storage_used_gb(facts),
"cpu_count": cpu_count(facts),
"custom_fields": {
"CPU_LogicalProcessors": cpu_logical_processors(facts)
}
"operating_system": facts["ansible_distribution"],
"operating_system_version": facts["ansible_distribution_version"],
"cpu_name": cpu_name(facts["ansible_processor"]),
Expand Down
3 changes: 2 additions & 1 deletion windows/server_stats.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ $ServerStats = {
CPU_Description = $cpu.Description
CPU_Manufacturer = $cpu.Manufacturer
CPU_L2CacheSize = $cpu.L2CacheSize
CPU_L3CacheSize = $cpu.L3CacheSize
CPU_L3CacheSize = $cpu.L3CacheSize
CPU_LogicalProcessors = $cpu.NumberOfLogicalProcessors
CPU_SocketDesignation = $cpu.SocketDesignation
TotalVisible_Memory_GB = $OSTotalVisibleMemory
TotalVirtual_Memory_GB = $OSTotalVirtualMemory
Expand Down

0 comments on commit b8fe02e

Please sign in to comment.