|
21 | 21 |
|
22 | 22 | - name: get memory information |
23 | 23 | win_shell: | |
24 | | - Get-WmiObject Win32_PhysicalMemory |
| 24 | + Get-WmiObject Win32_PhysicalMemory |ConvertTo-Json -Depth 3 |
25 | 25 | register: meminfo |
26 | 26 |
|
| 27 | +- name: Set Memory Channel info from meminfo |
| 28 | + set_fact: |
| 29 | + memchannelinfo: "{{ (meminfo.stdout | from_json | map(attribute='BankLabel') | select('defined') | map('regex_replace', '(DIMM.*)', '') | list | unique | length) }}" |
| 30 | + |
| 31 | +- name: Get CPU information |
| 32 | + win_shell: | |
| 33 | + Get-CimInstance Win32_Processor | Select-Object DeviceID, Name, Caption, NumberOfCores, NumberOfLogicalProcessors, MaxClockSpeed, Architecture, L2CacheSize, L3CacheSize, @{Name="NUMANode";Expression={(Get-CimInstance Win32_Processor | Select-Object -ExpandProperty DeviceID)}} | ConvertTo-Json |
| 34 | + register: cpuinfo |
| 35 | + |
| 36 | +- name: Get Disk Information |
| 37 | + win_shell: | |
| 38 | + Get-PhysicalDisk | ConvertTo-Json |
| 39 | + register: diskinfo |
| 40 | + |
| 41 | +- name: Get Chassis Information |
| 42 | + win_shell: | |
| 43 | + Get-WmiObject -Class Win32_SystemEnclosure | Select-Object ChassisTypes, Status, LockPresent, SecurityStatus, Manufacturer, Model, SerialNumber | ConvertTo-Json |
| 44 | + register: chassisinfo |
| 45 | + |
| 46 | +- name: Get GPU information |
| 47 | + win_shell: | |
| 48 | + Get-WmiObject -Class Win32_VideoController | ConvertTo-Json |
| 49 | + register: gpuinfo |
| 50 | + |
| 51 | +- name: Get PCIe device information |
| 52 | + win_shell: | |
| 53 | + Get-WmiObject Win32_PnPEntity | Where-Object { $_.PNPDeviceID -like "PCI*" } | |
| 54 | + Select-Object Name, @{Name='BusAddress'; Expression={$_.PNPDeviceID}}, Manufacturer, PNPClass, Present, Status, Service | |
| 55 | + ConvertTo-Json |
| 56 | + register: pcieinfo |
| 57 | + |
| 58 | +- name: Get acclerators information |
| 59 | + win_shell: | |
| 60 | + Get-PnpDevice | Where-Object { |
| 61 | + ($_.FriendlyName -match 'DLB|DSA|IAA|QAT|GNA|AI Boost|VPU|vRAN|AMX|FPGA|PAC|Arria|Stratix|NPU|TPU|AI Engine|Deep Learning|Inference|ML Accelerator|Edge TPU|GPU|Graphics|Video Controller|Compute Adapter|CUDA|Tensor|T4|A100|H100|RTX|Quadro|Tesla|Crypto|Compression|NVMe|Storage Accelerator|DPU|SmartNIC|Coprocessor|Accelerator|AI|Gaudi') -and |
| 62 | + ($_.Class -ne "HIDClass")} | Select-Object Status, Class, @{Name='Name'; Expression={$_.FriendlyName}}, Manufacturer, Service, Present, Problem | ConvertTo-Json |
| 63 | + register: acceleratorsinfo |
| 64 | + |
| 65 | +- name: Get Sensor Information |
| 66 | + win_shell: | |
| 67 | + Get-CimInstance -Namespace root/wmi -ClassName MSAcpi_ThermalZoneTemperature | Select-Object InstanceName, @{Name="CurrentTemperatureCelsius"; Expression={($_.CurrentTemperature - 2732) / 10}}, Active | ConvertTo-Json |
| 68 | + register: sensorinfo |
| 69 | + ignore_errors: true |
| 70 | + |
| 71 | +- name: Get Running Microcode Version |
| 72 | + win_shell: | |
| 73 | + $RegPath = "HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0" |
| 74 | + $UpdateRevision = (Get-ItemProperty -Path $RegPath -Name "Update Revision")."Update Revision" |
| 75 | + $RunningMicrocode = $UpdateRevision[0..4] -join '' |
| 76 | + $MicrocodeHex = [String]::Format("{0:x2}", [int]($RunningMicrocode.ToString()).TrimStart('0')) |
| 77 | + $MicrocodeHex.ToUpper() |
| 78 | + register: microcodeinfo |
| 79 | + |
| 80 | +- name: Get Network Interfaces |
| 81 | + win_shell: | |
| 82 | + Get-NetAdapter | Select-Object Name, Status, MacAddress, LinkSpeed, MediaType, InterfaceDescription | ConvertTo-Json |
| 83 | + register: netinfo |
| 84 | + |
| 85 | +- name: Get Base Board Information |
| 86 | + win_shell: | |
| 87 | + Get-WmiObject -Class Win32_BaseBoard | Select-Object Manufacturer, Product, SerialNumber, Version, PoweredOn | ConvertTo-Json |
| 88 | + register: baseboardinfo |
| 89 | + |
| 90 | +- name: Get System Information |
| 91 | + win_shell: | |
| 92 | + Get-WmiObject -Class Win32_ComputerSystem | Select-Object Manufacturer, Model, Name, SystemType, TotalPhysicalMemory, NumberOfProcessors, NumberOfLogicalProcessors, Domain, Workgroup, BootupState | ConvertTo-Json |
| 93 | + register: systeminfo |
| 94 | + |
| 95 | + |
27 | 96 | - name: Generate svrinfo json |
28 | 97 | template: |
29 | | - src: perfspect.json.j2 |
| 98 | + src: perfspect-win.json.j2 |
30 | 99 | dest: "{{ wl_logs_dir }}/{{ inventory_hostname }}-sutinfo/{{ private_ip | default(ansible_host) }}.json" |
31 | 100 | delegate_to: localhost |
32 | 101 | ignore_errors: true |
33 | 102 | vars: |
34 | | - mem_spec: "{% for c in (meminfo.stdout_lines | select('match','^Capacity *:.*') | map('split',':') | map('last') | map('trim') | map('int')) %}{{ (c / (1024*1024)) | int }}MB {% endfor %}" |
35 | | - mem_spec_list: "{{ mem_spec | split(' ') | reject('==','') }}" |
36 | | - |
| 103 | + numainfo: "{{ numainfo }}" |
| 104 | + memInfo: "{{ meminfo.stdout | from_json }}" |
| 105 | + ansible_devices: "{{ hostvars[inventory_hostname].ansible_devices | default({}) }}" |
| 106 | + ansible_mounts: "{{ hostvars[inventory_hostname].ansible_mounts | default([]) }}" |
| 107 | + ansible_interfaces: "{{ hostvars[inventory_hostname].ansible_interfaces | default([]) }}" |
| 108 | + cpuInfo: "{{ (cpuinfo.stdout | from_json) if (cpuinfo.stdout is defined and cpuinfo.stdout | length > 0) else [] }}" |
| 109 | + memChannelCount: "{{ memchannelinfo | int }}" |
| 110 | + disks: "{{ (diskinfo.stdout | from_json) if (diskinfo.stdout is defined and diskinfo.stdout | length > 0) else [] }}" |
| 111 | + chassis: "{{ (chassisinfo.stdout | from_json) if (chassisinfo.stdout is defined and chassisinfo.stdout | length > 0) else [] }}" |
| 112 | + gpus: "{{ (gpuinfo.stdout | from_json) if (gpuinfo.stdout is defined and gpuinfo.stdout | length > 0) else [] }}" |
| 113 | + pcie_devices: "{{ (pcieinfo.stdout | from_json) if (pcieinfo.stdout is defined and pcieinfo.stdout | length > 0) else [] }}" |
| 114 | + accelerators: "{{ (acceleratorsinfo.stdout | from_json) if (acceleratorsinfo.stdout is defined and acceleratorsinfo.stdout | length > 0) else [] }}" |
| 115 | + microcode: "{{ microcodeinfo.stdout}}" |
| 116 | + nicInfo: "{{ (netinfo.stdout | from_json) if (netinfo.stdout is defined and netinfo.stdout | length > 0) else [] }}" |
| 117 | + baseboard: "{{ (baseboardinfo.stdout | from_json) if (baseboardinfo.stdout is defined and baseboardinfo.stdout | length > 0) else {} }}" |
| 118 | + system: "{{ (systeminfo.stdout | from_json) if (systeminfo.stdout is defined and systeminfo.stdout | length > 0) else {} }}" |
| 119 | + sensors: "{{ (sensorinfo.stdout | from_json) if (sensorinfo.stdout is defined and sensorinfo.stdout | length > 0) else [] }}" |
| 120 | + kernellogs: "{{ (kernellogsinfo.stdout | from_json) if (kernellogsinfo.stdout is defined and kernellogsinfo.stdout | length > 0) else [] }}" |
| 121 | + memTypeMap: |
| 122 | + 20: 'DDR' |
| 123 | + 21: 'DDR2' |
| 124 | + 24: 'DDR3' |
| 125 | + 26: 'DDR4' |
| 126 | + 34: 'DDR5' |
| 127 | + 0: 'Unknown' |
0 commit comments