diff --git a/lib/ohai/plugins/cpu.rb b/lib/ohai/plugins/cpu.rb index 510c20185..c6b4e718b 100644 --- a/lib/ohai/plugins/cpu.rb +++ b/lib/ohai/plugins/cpu.rb @@ -63,7 +63,8 @@ def range_str_to_a(range) def parse_lscpu(cpu_info) lscpu_info = Mash.new begin - so = shell_out("lscpu") + # Pipe to cat to retain previous output on newer util-linux (see lscpu(1)) + so = shell_out("lscpu | cat") cpu_cores = shell_out("lscpu -p=CPU,CORE,SOCKET") if so.exitstatus == 0 && cpu_cores.exitstatus == 0 lscpu_info[:numa_node_cpus] = Mash.new @@ -96,10 +97,12 @@ def parse_lscpu(cpu_info) end when /^Thread\(s\) per core:\s+(.+)/ # http://rubular.com/r/lOw2pRrw1q lscpu_info[:threads_per_core] = $1.to_i - when /^Core\(s\) per socket:\s+(.+)/ # http://rubular.com/r/lOw2pRrw1q + when /^Core\(s\) per (?:socket|cluster):\s+(.+)/ # http://rubular.com/r/lOw2pRrw1q lscpu_info[:cores_per_socket] = $1.to_i when /^Socket\(s\):\s+(.+)/ # http://rubular.com/r/DIzmPtJFvK lscpu_info[:sockets] = $1.to_i + when /^Clusters\(s\):\s+(.+)/ + lscpu_info[:clusters] = $1.to_i when /^Socket\(s\) per book:\s+(.+)/ lscpu_info[:sockets_per_book] = $1.to_i when /^Book\(s\) per drawer:\s+(.+)/ @@ -110,6 +113,10 @@ def parse_lscpu(cpu_info) lscpu_info[:numa_nodes] = $1.to_i when /^Vendor ID:\s+(.+)/ lscpu_info[:vendor_id] = $1 + when /^BIOS Vendor ID:\s+(.+)/ + lscpu_info[:bios_vendor_id] = $1 + when /^BIOS Model name:\s+(.+)/ + lscpu_info[:bios_model_name] = $1.strip when /^Machine type:\s+(.+)/ lscpu_info[:machine_type] = $1 when /^CPU family:\s+(.+)/ diff --git a/spec/data/plugins/cpuinfo-aarch64-guest-kvm-rhel9.output b/spec/data/plugins/cpuinfo-aarch64-guest-kvm-rhel9.output new file mode 100644 index 000000000..5b65347b3 --- /dev/null +++ b/spec/data/plugins/cpuinfo-aarch64-guest-kvm-rhel9.output @@ -0,0 +1,18 @@ +processor : 0 +BogoMIPS : 80.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +CPU implementer : 0x50 +CPU architecture: 8 +CPU variant : 0x3 +CPU part : 0x000 +CPU revision : 2 + +processor : 1 +BogoMIPS : 80.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +CPU implementer : 0x50 +CPU architecture: 8 +CPU variant : 0x3 +CPU part : 0x000 +CPU revision : 2 + diff --git a/spec/data/plugins/cpuinfo-ppc64le-p9-guest-kvm-rhel9.output b/spec/data/plugins/cpuinfo-ppc64le-p9-guest-kvm-rhel9.output new file mode 100644 index 000000000..94ac610fb --- /dev/null +++ b/spec/data/plugins/cpuinfo-ppc64le-p9-guest-kvm-rhel9.output @@ -0,0 +1,15 @@ +processor : 0 +cpu : POWER9 (architected), altivec supported +clock : 2200.000000MHz +revision : 2.2 (pvr 004e 1202) + +processor : 1 +cpu : POWER9 (architected), altivec supported +clock : 2200.000000MHz +revision : 2.2 (pvr 004e 1202) + +timebase : 512000000 +platform : pSeries +model : IBM pSeries (emulated by qemu) +machine : CHRP IBM pSeries (emulated by qemu) +MMU : Radix diff --git a/spec/data/plugins/cpuinfo-x86-guest-kvm-nested-rhel9.output b/spec/data/plugins/cpuinfo-x86-guest-kvm-nested-rhel9.output new file mode 100644 index 000000000..05b54f18a --- /dev/null +++ b/spec/data/plugins/cpuinfo-x86-guest-kvm-nested-rhel9.output @@ -0,0 +1,55 @@ +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel Core Processor (Haswell, no TSX, IBRS) +stepping : 1 +microcode : 0x1 +cpu MHz : 2394.454 +cache size : 16384 KB +physical id : 0 +siblings : 1 +core id : 0 +cpu cores : 1 +apicid : 0 +initial apicid : 0 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat md_clear +vmx flags : vnmi preemption_timer posted_intr invvpid ept_x_only ept_ad ept_1gb flexpriority apicv tsc_offset vtpr mtf vapic ept vpid unrestricted_guest vapic_reg vid pml +bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbds mmio_unknown +bogomips : 4788.90 +clflush size : 64 +cache_alignment : 64 +address sizes : 46 bits physical, 48 bits virtual +power management: + +processor : 1 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel Core Processor (Haswell, no TSX, IBRS) +stepping : 1 +microcode : 0x1 +cpu MHz : 2394.454 +cache size : 16384 KB +physical id : 1 +siblings : 1 +core id : 0 +cpu cores : 1 +apicid : 1 +initial apicid : 1 +fpu : yes +fpu_exception : yes +cpuid level : 13 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat md_clear +vmx flags : vnmi preemption_timer posted_intr invvpid ept_x_only ept_ad ept_1gb flexpriority apicv tsc_offset vtpr mtf vapic ept vpid unrestricted_guest vapic_reg vid pml +bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit srbds mmio_unknown +bogomips : 4788.90 +clflush size : 64 +cache_alignment : 64 +address sizes : 46 bits physical, 48 bits virtual +power management: diff --git a/spec/data/plugins/lscpu-aarch64-guest-kvm-cores-rhel9.output b/spec/data/plugins/lscpu-aarch64-guest-kvm-cores-rhel9.output new file mode 100644 index 000000000..b31833ad8 --- /dev/null +++ b/spec/data/plugins/lscpu-aarch64-guest-kvm-cores-rhel9.output @@ -0,0 +1,6 @@ +# The following is the parsable format, which can be fed to other +# programs. Each different item in every column has an unique ID +# starting usually from zero. +# CPU,Core,Socket +0,0,0 +1,1,0 diff --git a/spec/data/plugins/lscpu-aarch64-guest-kvm-rhel9.output b/spec/data/plugins/lscpu-aarch64-guest-kvm-rhel9.output new file mode 100644 index 000000000..0b77572cb --- /dev/null +++ b/spec/data/plugins/lscpu-aarch64-guest-kvm-rhel9.output @@ -0,0 +1,29 @@ +Architecture: aarch64 +CPU op-mode(s): 32-bit, 64-bit +Byte Order: Little Endian +CPU(s): 2 +On-line CPU(s) list: 0,1 +Vendor ID: APM +BIOS Vendor ID: QEMU +BIOS Model name: virt-rhel7.6.0 +Model: 2 +Thread(s) per core: 1 +Core(s) per cluster: 2 +Socket(s): 2 +Cluster(s): 1 +Stepping: 0x3 +BogoMIPS: 80.00 +Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +NUMA node(s): 1 +NUMA node0 CPU(s): 0,1 +Vulnerability Itlb multihit: Not affected +Vulnerability L1tf: Not affected +Vulnerability Mds: Not affected +Vulnerability Meltdown: Mitigation; PTI +Vulnerability Mmio stale data: Not affected +Vulnerability Retbleed: Not affected +Vulnerability Spec store bypass: Vulnerable +Vulnerability Spectre v1: Mitigation; __user pointer sanitization +Vulnerability Spectre v2: Vulnerable +Vulnerability Srbds: Not affected +Vulnerability Tsx async abort: Not affected diff --git a/spec/data/plugins/lscpu-aarch64-host-rhel9.output b/spec/data/plugins/lscpu-aarch64-host-rhel9.output new file mode 100644 index 000000000..4c3ad7d7f --- /dev/null +++ b/spec/data/plugins/lscpu-aarch64-host-rhel9.output @@ -0,0 +1,34 @@ +Architecture: aarch64 +CPU op-mode(s): 32-bit, 64-bit +Byte Order: Little Endian +CPU(s): 32 +On-line CPU(s) list: 0-31 +Vendor ID: APM +BIOS Vendor ID: Ampere(TM) +BIOS Model name: eMAG +Model: 2 +Thread(s) per core: 1 +Core(s) per socket: 32 +Socket(s): 1 +Stepping: 0x3 +Frequency boost: disabled +CPU max MHz: 3000.0000 +CPU min MHz: 375.0000 +BogoMIPS: 80.00 +Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid +L1d cache: 1 MiB (32 instances) +L1i cache: 1 MiB (32 instances) +L2 cache: 4 MiB (16 instances) +NUMA node(s): 1 +NUMA node0 CPU(s): 0-31 +Vulnerability Itlb multihit: Not affected +Vulnerability L1tf: Not affected +Vulnerability Mds: Not affected +Vulnerability Meltdown: Mitigation; PTI +Vulnerability Mmio stale data: Not affected +Vulnerability Retbleed: Not affected +Vulnerability Spec store bypass: Vulnerable +Vulnerability Spectre v1: Mitigation; __user pointer sanitization +Vulnerability Spectre v2: Vulnerable +Vulnerability Srbds: Not affected +Vulnerability Tsx async abort: Not affected diff --git a/spec/data/plugins/lscpu-ppc64le-p8-host-debian12.output b/spec/data/plugins/lscpu-ppc64le-p8-host-debian12.output new file mode 100644 index 000000000..ec834e562 --- /dev/null +++ b/spec/data/plugins/lscpu-ppc64le-p8-host-debian12.output @@ -0,0 +1,34 @@ +Architecture: ppc64le +Byte Order: Little Endian +CPU(s): 160 +On-line CPU(s) list: 0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152 +Off-line CPU(s) list: 1-7,9-15,17-23,25-31,33-39,41-47,49-55,57-63,65-71,73-79,81-87,89-95,97-103,105-111,11 +9,121-127,129-135,137-143,145-151,153-159 +Model name: POWER8E (raw), altivec supported +Model: 2.1 (pvr 004b 0201) +Thread(s) per core: 1 +Core(s) per socket: 5 +Socket(s): 4 +CPU(s) scaling MHz: 100% +CPU max MHz: 3690.0000 +CPU min MHz: 2061.0000 +L1d cache: 1.3 MiB (20 instances) +L1i cache: 640 KiB (20 instances) +L2 cache: 10 MiB (20 instances) +L3 cache: 160 MiB (20 instances) +NUMA node(s): 4 +NUMA node0 CPU(s): 0,8,16,24,32 +NUMA node1 CPU(s): 40,48,56,64,72 +NUMA node16 CPU(s): 80,88,96,104,112 +NUMA node17 CPU(s): 120,128,136,144,152 +Vulnerability Itlb multihit: Not affected +Vulnerability L1tf: Not affected +Vulnerability Mds: Not affected +Vulnerability Meltdown: Mitigation; RFI Flush +Vulnerability Mmio stale data: Not affected +Vulnerability Retbleed: Not affected +Vulnerability Spec store bypass: Mitigation; Kernel entry/exit barrier (hwsync) +Vulnerability Spectre v1: Mitigation; __user pointer sanitization, ori31 speculation barrier enabled +Vulnerability Spectre v2: Mitigation; Indirect branch cache disabled, Software link stack flush +Vulnerability Srbds: Not affected +Vulnerability Tsx async abort: Not affected diff --git a/spec/data/plugins/lscpu-ppc64le-p9-guest-kvm-cores-rhel9.output b/spec/data/plugins/lscpu-ppc64le-p9-guest-kvm-cores-rhel9.output new file mode 100644 index 000000000..c0fd99f9d --- /dev/null +++ b/spec/data/plugins/lscpu-ppc64le-p9-guest-kvm-cores-rhel9.output @@ -0,0 +1,6 @@ +# The following is the parsable format, which can be fed to other +# programs. Each different item in every column has an unique ID +# starting usually from zero. +# CPU,Core,Socket +0,0,0 +1,1,1 diff --git a/spec/data/plugins/lscpu-ppc64le-p9-guest-kvm-rhel9.output b/spec/data/plugins/lscpu-ppc64le-p9-guest-kvm-rhel9.output new file mode 100644 index 000000000..e3f995f32 --- /dev/null +++ b/spec/data/plugins/lscpu-ppc64le-p9-guest-kvm-rhel9.output @@ -0,0 +1,26 @@ +Architecture: ppc64le +Byte Order: Little Endian +CPU(s): 2 +On-line CPU(s) list: 0,1 +Model name: POWER9 (architected), altivec supported +Model: 2.2 (pvr 004e 1202) +Thread(s) per core: 1 +Core(s) per socket: 1 +Socket(s): 2 +Hypervisor vendor: KVM +Virtualization type: para +L1d cache: 64 KiB (2 instances) +L1i cache: 64 KiB (2 instances) +NUMA node(s): 1 +NUMA node0 CPU(s): 0,1 +Vulnerability Itlb multihit: Not affected +Vulnerability L1tf: Mitigation; RFI Flush +Vulnerability Mds: Not affected +Vulnerability Meltdown: Mitigation; RFI Flush +Vulnerability Mmio stale data: Not affected +Vulnerability Retbleed: Not affected +Vulnerability Spec store bypass: Mitigation; Kernel entry/exit barrier (eieio) +Vulnerability Spectre v1: Mitigation; __user pointer sanitization +Vulnerability Spectre v2: Vulnerable +Vulnerability Srbds: Not affected +Vulnerability Tsx async abort: Not affected diff --git a/spec/data/plugins/lscpu-ppc64le-p9-host-rhel9.output b/spec/data/plugins/lscpu-ppc64le-p9-host-rhel9.output new file mode 100644 index 000000000..a2a6a5f15 --- /dev/null +++ b/spec/data/plugins/lscpu-ppc64le-p9-host-rhel9.output @@ -0,0 +1,34 @@ +Architecture: ppc64le +Byte Order: Little Endian +CPU(s): 128 +On-line CPU(s) list: 0-127 +Model name: POWER9, altivec supported +Model: 2.3 (pvr 004e 1203) +Thread(s) per core: 4 +Core(s) per socket: 16 +Socket(s): 2 +Frequency boost: enabled +CPU max MHz: 3800.0000 +CPU min MHz: 2300.0000 +L1d cache: 1 MiB (32 instances) +L1i cache: 1 MiB (32 instances) +L2 cache: 8 MiB (16 instances) +L3 cache: 160 MiB (16 instances) +NUMA node(s): 6 +NUMA node0 CPU(s): 0-63 +NUMA node8 CPU(s): 64-127 +NUMA node252 CPU(s): +NUMA node253 CPU(s): +NUMA node254 CPU(s): +NUMA node255 CPU(s): +Vulnerability Itlb multihit: Not affected +Vulnerability L1tf: Not affected +Vulnerability Mds: Not affected +Vulnerability Meltdown: Mitigation; RFI Flush, L1D private per thread +Vulnerability Mmio stale data: Not affected +Vulnerability Retbleed: Not affected +Vulnerability Spec store bypass: Mitigation; Kernel entry/exit barrier (eieio) +Vulnerability Spectre v1: Mitigation; __user pointer sanitization, ori31 speculation barrier enabled +Vulnerability Spectre v2: Mitigation; Software count cache flush (hardware accelerated), Software link stack flush +Vulnerability Srbds: Not affected +Vulnerability Tsx async abort: Not affected diff --git a/spec/data/plugins/lscpu-x86-guest-kvm-nested-cores-rhel9.output b/spec/data/plugins/lscpu-x86-guest-kvm-nested-cores-rhel9.output new file mode 100644 index 000000000..c0fd99f9d --- /dev/null +++ b/spec/data/plugins/lscpu-x86-guest-kvm-nested-cores-rhel9.output @@ -0,0 +1,6 @@ +# The following is the parsable format, which can be fed to other +# programs. Each different item in every column has an unique ID +# starting usually from zero. +# CPU,Core,Socket +0,0,0 +1,1,1 diff --git a/spec/data/plugins/lscpu-x86-guest-kvm-nested-rhel9.output b/spec/data/plugins/lscpu-x86-guest-kvm-nested-rhel9.output new file mode 100644 index 000000000..e178590f1 --- /dev/null +++ b/spec/data/plugins/lscpu-x86-guest-kvm-nested-rhel9.output @@ -0,0 +1,38 @@ +Architecture: x86_64 +CPU op-mode(s): 32-bit, 64-bit +Address sizes: 46 bits physical, 48 bits virtual +Byte Order: Little Endian +CPU(s): 2 +On-line CPU(s) list: 0,1 +Vendor ID: GenuineIntel +BIOS Vendor ID: Red Hat +Model name: Intel Core Processor (Haswell, no TSX, IBRS) +BIOS Model name: RHEL 7.6.0 PC (i440FX + PIIX, 1996) +CPU family: 6 +Model: 60 +Thread(s) per core: 1 +Core(s) per socket: 1 +Socket(s): 2 +Stepping: 1 +BogoMIPS: 4788.90 +Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat md_clear +Virtualization: VT-x +Hypervisor vendor: KVM +Virtualization type: full +L1d cache: 64 KiB (2 instances) +L1i cache: 64 KiB (2 instances) +L2 cache: 8 MiB (2 instances) +L3 cache: 32 MiB (2 instances) +NUMA node(s): 1 +NUMA node0 CPU(s): 0,1 +Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled +Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT disabled +Vulnerability Mds: Mitigation; Clear CPU buffers; SMT Host state unknown +Vulnerability Meltdown: Mitigation; PTI +Vulnerability Mmio stale data: Unknown: No mitigations +Vulnerability Retbleed: Not affected +Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl +Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization +Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected +Vulnerability Srbds: Unknown: Dependent on hypervisor status +Vulnerability Tsx async abort: Not affected diff --git a/spec/data/plugins/lscpu-x86-host-rhel9.output b/spec/data/plugins/lscpu-x86-host-rhel9.output new file mode 100644 index 000000000..ff38f859f --- /dev/null +++ b/spec/data/plugins/lscpu-x86-host-rhel9.output @@ -0,0 +1,38 @@ +Architecture: x86_64 +CPU op-mode(s): 32-bit, 64-bit +Address sizes: 40 bits physical, 48 bits virtual +Byte Order: Little Endian +CPU(s): 12 +On-line CPU(s) list: 0-11 +Vendor ID: GenuineIntel +Model name: Intel(R) Xeon(R) CPU X5680 @ 3.33GHz +CPU family: 6 +Model: 44 +Thread(s) per core: 1 +Core(s) per socket: 6 +Socket(s): 2 +Stepping: 2 +Frequency boost: enabled +CPU max MHz: 3326.0000 +CPU min MHz: 1596.0000 +BogoMIPS: 6649.64 +Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid dtherm ida arat flush_l1d +Virtualization: VT-x +L1d cache: 384 KiB (12 instances) +L1i cache: 384 KiB (12 instances) +L2 cache: 3 MiB (12 instances) +L3 cache: 24 MiB (2 instances) +NUMA node(s): 2 +NUMA node0 CPU(s): 0,2,4,6,8,10 +NUMA node1 CPU(s): 1,3,5,7,9,11 +Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled +Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT disabled +Vulnerability Mds: Vulnerable: Clear CPU buffers attempted, no microcode; SMT disabled +Vulnerability Meltdown: Mitigation; PTI +Vulnerability Mmio stale data: Not affected +Vulnerability Retbleed: Not affected +Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl +Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization +Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, IBRS_FW, RSB filling, PBRSB-eIBRS Not affected +Vulnerability Srbds: Not affected +Vulnerability Tsx async abort: Not affected diff --git a/spec/unit/plugins/linux/cpu_spec.rb b/spec/unit/plugins/linux/cpu_spec.rb index c011a2bdc..bd34047e4 100644 --- a/spec/unit/plugins/linux/cpu_spec.rb +++ b/spec/unit/plugins/linux/cpu_spec.rb @@ -377,7 +377,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(1, "", "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(1, "", "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(1, "", "")) end @@ -471,7 +471,7 @@ before do allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -516,11 +516,57 @@ end end + context "RHEL9 x86 host cpu with lscpu" do + let(:cpuinfo_contents) { File.read(File.join(SPEC_PLUGIN_PATH, "cpuinfo-no-cores.output")) } + let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-x86-host-rhel9.output")) } + let(:lscpu_cores) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-x86-host-cores.output")) } + + before do + allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) + end + + flags = %w{acpi aes aperfmperf apic arat arch_perfmon bts clflush cmov constant_tsc cpuid cx16 cx8 dca de ds_cpl dtes64 dtherm dts epb ept est flexpriority flush_l1d fpu fxsr ht ibpb ibrs ida lahf_lm lm mca mce mmx monitor msr mtrr nonstop_tsc nopl nx pae pat pbe pcid pclmulqdq pdcm pdpe1gb pebs pge pni popcnt pse pse36 pti rdtscp rep_good sep smx ssbd sse sse2 sse4_1 sse4_2 ssse3 stibp syscall tm tm2 tpr_shadow tsc vme vmx vnmi vpid xtopology xtpr} + numa_node_cpus = { "0" => [0, 2, 4, 6, 8, 10], "1" => [1, 3, 5, 7, 9, 11] } + + it_behaves_like "Common cpu info", + "0", # default_cpu + 12, # total_cpu + 2, # real_cpu + true, # ls_cpu + "x86_64", # architecture + %w{32-bit 64-bit}, # cpu_opmodes + "little endian", # byte_order + 12, # cpus + 12, # cpus_online + 1, # threads_per_core + 6, # cores_per_socket + 2, # sockets + 2, # numa_nodes + "GenuineIntel", # vendor_id + "44", # model + "Intel(R) Xeon(R) CPU X5680 @ 3.33GHz", # model_name + "6649.64", # bogomips + "384 KiB (12 instances)", # l1d_cache + "384 KiB (12 instances)", # l1i_cache + "3 MiB (12 instances)", # l2_cache + "24 MiB (2 instances)", # l3_cache + flags, # flags + numa_node_cpus # numa_node_cpus + + it "has virtualization" do + plugin.run + expect(plugin[:cpu]).to have_key("virtualization") + expect(plugin[:cpu]["virtualization"]).to eq("VT-x") + end + end + context "with a dual-core hyperthreaded /proc/cpuinfo" do let(:cpuinfo_contents) { File.read(File.join(SPEC_PLUGIN_PATH, "cpuinfo-dual-core-hyperthreaded.output")) } before do - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(1, "", "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(1, "", "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(1, "", "")) end @@ -547,7 +593,7 @@ before do allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -610,7 +656,7 @@ before do allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -659,7 +705,7 @@ before do allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -707,6 +753,55 @@ end end + context "x86 RHEL9 guest on kvm (nested)" do + let(:cpuinfo_contents) { File.read(File.join(SPEC_PLUGIN_PATH, "cpuinfo-x86-guest-kvm-nested-rhel9.output")) } + let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-x86-guest-kvm-nested-rhel9.output")) } + let(:lscpu_cores) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-x86-guest-kvm-nested-cores-rhel9.output")) } + + before do + allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) + end + + flags = %w{abm aes apic arat avx avx2 bmi1 bmi2 clflush cmov constant_tsc cpuid cx16 cx8 de ept ept_ad erms f16c flexpriority fma fpu fsgsbase fxsr hypervisor ibpb ibrs invpcid invpcid_single lahf_lm lm mca mce md_clear mmx movbe msr mtrr nopl nx pae pat pcid pclmulqdq pdpe1gb pge pni popcnt pse pse36 pti rdrand rdtscp rep_good sep smep ss ssbd sse sse2 sse4_1 sse4_2 ssse3 stibp syscall tpr_shadow tsc tsc_adjust tsc_deadline_timer tsc_known_freq vme vmx vnmi vpid x2apic xsave xsaveopt xtopology} + numa_node_cpus = { "0" => [0, 1] } + + it_behaves_like "Common cpu info", + "0", # default_cpu + 2, # total_cpu + 2, # real_cpu + true, # ls_cpu + "x86_64", # architecture + %w{32-bit 64-bit}, # cpu_opmodes + "little endian", # byte_order + 2, # cpus + 2, # cpus_online + 1, # threads_per_core + 1, # cores_per_socket + 2, # sockets + 1, # numa_nodes + "GenuineIntel", # vendor_id + "60", # model + "Intel Core Processor (Haswell, no TSX, IBRS)", # model_name + "4788.90", # bogomips + "64 KiB (2 instances)", # l1d_cache + "64 KiB (2 instances)", # l1i_cache + "8 MiB (2 instances)", # l2_cache + "32 MiB (2 instances)", # l3_cache + flags, # flags + numa_node_cpus # numa_node_cpus + it_behaves_like "virtualization info", + "full", # virtualization_type + "KVM" # hypervisor_vendor + + it "has virtualization" do + plugin.run + expect(plugin[:cpu]).to have_key("virtualization") + expect(plugin[:cpu]["virtualization"]).to eq("VT-x") + end + end + context "x86 guest on xen" do let(:cpuinfo_contents) { File.read(File.join(SPEC_PLUGIN_PATH, "cpuinfo-x86-guest-xen.output")) } let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-x86-guest-xen.output")) } @@ -714,7 +809,7 @@ before do allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -763,7 +858,7 @@ before do allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -824,7 +919,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(1, "", "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(1, "", "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(1, "", "")) end @@ -867,7 +962,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -1003,7 +1098,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(1, "", "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(1, "", "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(1, "", "")) end @@ -1030,7 +1125,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -1088,6 +1183,82 @@ end end + context "RHEL9 with lscpu data" do + let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-aarch64-host-rhel9.output")) } + let(:lscpu_cores) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-aarch64-host-cores.output")) } + + before do + allow(plugin).to receive(:collect_os).and_return(:linux) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) + end + + flags = %w{aes asimd cpuid crc32 evtstrm fp pmull sha1 sha2} + numa_node_cpus = { "0" => Range.new(0, 31).to_a } + + it_behaves_like "Common cpu info", + "0", # default_cpu + 32, # total_cpu + 1, # real_cpu + true, # ls_cpu + "aarch64", # architecture + %w{32-bit 64-bit}, # cpu_opmodes + "little endian", # byte_order + 32, # cpus + 32, # cpus_online + 1, # threads_per_core + 32, # cores_per_socket + 1, # sockets + 1, # numa_nodes + "APM", # vendor_id + "2", # model + nil, # model_name + "80.00", # bogomips + "1 MiB (32 instances)", # l1d_cache + "1 MiB (32 instances)", # l1i_cache + "4 MiB (16 instances)", # l2_cache + nil, # l3_cache + flags, # flags + numa_node_cpus # numa_node_cpus + it_behaves_like "arm64 processor info", + 0, # cpu_no + "80.00", # bogomips + flags # features + it_behaves_like "arm64 processor info", + 1, # cpu_no + "80.00", # bogomips + flags # features + + it "has a cpu 1" do + plugin.run + expect(plugin[:cpu]).to have_key("1") + end + + it "has mhz_max" do + plugin.run + expect(plugin[:cpu]).to have_key("mhz_max") + expect(plugin[:cpu]["mhz_max"]).to eq("3000.0000") + end + + it "has mhz_min" do + plugin.run + expect(plugin[:cpu]).to have_key("mhz_min") + expect(plugin[:cpu]["mhz_min"]).to eq("375.0000") + end + + it "has bios_vendor_id" do + plugin.run + expect(plugin[:cpu]).to have_key("bios_vendor_id") + expect(plugin[:cpu]["bios_vendor_id"]).to eq("Ampere(TM)") + end + + it "has bios_model_name" do + plugin.run + expect(plugin[:cpu]).to have_key("bios_model_name") + expect(plugin[:cpu]["bios_model_name"]).to eq("eMAG") + end + end + context "aarch64 kvm guest" do let(:cpuinfo_contents) { File.read(File.join(SPEC_PLUGIN_PATH, "cpuinfo-aarch64-guest-kvm.output")) } let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-aarch64-guest-kvm.output")) } @@ -1095,7 +1266,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -1132,6 +1303,68 @@ flags # features end + context "aarch64 kvm RHEL9 guest" do + let(:cpuinfo_contents) { File.read(File.join(SPEC_PLUGIN_PATH, "cpuinfo-aarch64-guest-kvm-rhel9.output")) } + let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-aarch64-guest-kvm-rhel9.output")) } + let(:lscpu_cores) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-aarch64-guest-kvm-cores-rhel9.output")) } + + before do + allow(plugin).to receive(:collect_os).and_return(:linux) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) + end + + flags = %w{aes asimd cpuid crc32 evtstrm fp pmull sha1 sha2} + numa_node_cpus = { "0" => Range.new(0, 1).to_a } + + it_behaves_like "Common cpu info", + "0", # default_cpu + 4, # total_cpu + 2, # real_cpu + true, # ls_cpu + "aarch64", # architecture + %w(32-bit 64-bit), # cpu_opmodes + "little endian", # byte_order + 2, # cpus + 2, # cpus_online + 1, # threads_per_core + 2, # cores_per_socket + 2, # sockets + 1, # numa_nodes + "APM", # vendor_id + "2", # model + nil, # model_name + "80.00", # bogomips + nil, # l1d_cache + nil, # l1i_cache + nil, # l2_cache + nil, # l3_cache + flags, # flags + numa_node_cpus # numa_node_cpus + it_behaves_like "arm64 processor info", + 0, # cpu_no + "80.00", # bogomips + flags # features + it "has vulnerability" do + plugin.run + vuln = { + "itlb_multihit" => "Not affected", + "l1tf" => "Not affected", + "mds" => "Not affected", + "meltdown" => "Mitigation; PTI", + "mmio_stale_data" => "Not affected", + "retbleed" => "Not affected", + "spec_store_bypass" => "Vulnerable", + "spectre_v1" => "Mitigation; __user pointer sanitization", + "spectre_v2" => "Vulnerable", + "srbds" => "Not affected", + "tsx_async_abort" => "Not affected", + } + expect(plugin[:cpu]).to have_key("vulnerability") + expect(plugin[:cpu]["vulnerability"]).to eq(vuln) + end + end + context "aarch64 graviton2 guest" do let(:cpuinfo_contents) { File.read(File.join(SPEC_PLUGIN_PATH, "cpuinfo-aarch64-graviton2.output")) } let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-aarch64-graviton2.output")) } @@ -1139,7 +1372,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -1190,7 +1423,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) allow(File).to receive(:open).with("/proc/cpuinfo").and_return(cpuinfo_contents) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(1, "", "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(1, "", "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(1, "", "")) end @@ -1216,7 +1449,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -1286,6 +1519,85 @@ end end + context "POWER9 host on RHEL9" do + let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-ppc64le-p9-host-rhel9.output")) } + let(:lscpu_cores) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-ppc64le-p9-host-cores.output")) } + + before do + allow(plugin).to receive(:collect_os).and_return(:linux) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) + end + + numa_node_cpus = + { + "0" => Range.new(0, 63).to_a, + "252" => [0], + "253" => [0], + "254" => [0], + "255" => [0], + "8" => Range.new(64, 127).to_a, + } + + it_behaves_like "Common cpu info", + "0", # default_cpu + 128, # total_cpu + 2, # real_cpu + true, # ls_cpu + "ppc64le", # architecture + nil, # cpu_opmodes + "little endian", # byte_order + 128, # cpus + 128, # cpus_online + 4, # threads_per_core + 16, # cores_per_socket + 2, # sockets + 6, # numa_nodes + nil, # vendor_id + "2.3 (pvr 004e 1203)", # model + "POWER9, altivec supported", # model_name + nil, # bogomips + "1 MiB (32 instances)", # l1d_cache + "1 MiB (32 instances)", # l1i_cache + "8 MiB (16 instances)", # l2_cache + "160 MiB (16 instances)", # l3_cache + nil, # flags + numa_node_cpus # numa_node_cpus + it_behaves_like "ppc64le processor info", + 0, # cpu_no + "POWER9, altivec supported", # model_name + "2.3 (pvr 004e 1203)", # model + "2166.000000MHz", # mhz + "512000000", # timebase + "PowerNV", # platform + "9006-12P", # machine_model + "PowerNV 9006-12P", # machine + "OPAL", # firmware + "Radix" # mmu + + it "has a cpu 0" do + plugin.run + expect(plugin[:cpu]).to have_key("0") + end + + it "not have cpus_offline" do + plugin.run + expect(plugin[:cpu]).to_not have_key("cpus_offline") + end + + it "has mhz_max" do + plugin.run + expect(plugin[:cpu]).to have_key("mhz_max") + expect(plugin[:cpu]["mhz_max"]).to eq("3800.0000") + end + + it "has mhz_min" do + plugin.run + expect(plugin[:cpu]).to have_key("mhz_min") + expect(plugin[:cpu]["mhz_min"]).to eq("2300.0000") + end + end + context "POWER8 host" do let(:cpuinfo_contents) { File.read(File.join(SPEC_PLUGIN_PATH, "cpuinfo-ppc64le-p8-host.output")) } let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-ppc64le-p8-host.output")) } @@ -1293,7 +1605,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -1365,6 +1677,85 @@ end end + context "POWER8 host on Debian 12" do + let(:cpuinfo_contents) { File.read(File.join(SPEC_PLUGIN_PATH, "cpuinfo-ppc64le-p8-host.output")) } + let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-ppc64le-p8-host-debian12.output")) } + let(:lscpu_cores) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-ppc64le-p8-host-cores.output")) } + + before do + allow(plugin).to receive(:collect_os).and_return(:linux) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) + end + + numa_node_cpus = + { + "0" => [0, 8, 16, 24, 32], + "1" => [40, 48, 56, 64, 72], + "16" => [80, 88, 96, 104, 112], + "17" => [120, 128, 136, 144, 152], + } + + it_behaves_like "Common cpu info", + "0", # default_cpu + 20, # total_cpu + 4, # real_cpu + true, # ls_cpu + "ppc64le", # architecture + nil, # cpu_opmodes + "little endian", # byte_order + 160, # cpus + 20, # cpus_online + 1, # threads_per_core + 5, # cores_per_socket + 4, # sockets + 4, # numa_nodes + nil, # vendor_id + "2.1 (pvr 004b 0201)", # model + "POWER8E (raw), altivec supported", # model_name + nil, # bogomips + "1.3 MiB (20 instances)", # l1d_cache + "640 KiB (20 instances)", # l1i_cache + "10 MiB (20 instances)", # l2_cache + "160 MiB (20 instances)", # l3_cache + nil, # flags + numa_node_cpus # numa_node_cpus + it_behaves_like "ppc64le processor info", + 0, # cpu_no + "POWER8E (raw), altivec supported", # model_name + "2.1 (pvr 004b 0201)", # model + "3690.000000MHz", # mhz + "512000000", # timebase + "PowerNV", # platform + "8247-22L", # machine_model + "PowerNV 8247-22L", # machine + "OPAL", # firmware + "Hash" # mmu + + it "has a cpu 0" do + plugin.run + expect(plugin[:cpu]).to have_key("0") + end + + it "has cpus_offline" do + plugin.run + expect(plugin[:cpu]).to have_key("cpus_offline") + expect(plugin[:cpu]["cpus_offline"]).to eq(99) + end + + it "has mhz_max" do + plugin.run + expect(plugin[:cpu]).to have_key("mhz_max") + expect(plugin[:cpu]["mhz_max"]).to eq("3690.0000") + end + + it "has mhz_min" do + plugin.run + expect(plugin[:cpu]).to have_key("mhz_min") + expect(plugin[:cpu]["mhz_min"]).to eq("2061.0000") + end + end + context "POWER8 KVM guest" do let(:cpuinfo_contents) { File.read(File.join(SPEC_PLUGIN_PATH, "cpuinfo-ppc64le-p8-guest-kvm.output")) } let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-ppc64le-p8-guest-kvm.output")) } @@ -1372,7 +1763,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -1431,7 +1822,7 @@ before do allow(plugin).to receive(:collect_os).and_return(:linux) - allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) end @@ -1482,4 +1873,63 @@ expect(plugin[:cpu]).to have_key("0") end end + + context "POWER9 KVM guest on RHEL9" do + let(:cpuinfo_contents) { File.read(File.join(SPEC_PLUGIN_PATH, "cpuinfo-ppc64le-p9-guest-kvm-rhel9.output")) } + let(:lscpu) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-ppc64le-p9-guest-kvm-rhel9.output")) } + let(:lscpu_cores) { File.read(File.join(SPEC_PLUGIN_PATH, "lscpu-ppc64le-p9-guest-kvm-cores.output")) } + + before do + allow(plugin).to receive(:collect_os).and_return(:linux) + allow(plugin).to receive(:shell_out).with("lscpu | cat").and_return(mock_shell_out(0, lscpu, "")) + allow(plugin).to receive(:shell_out).with("lscpu -p=CPU,CORE,SOCKET").and_return(mock_shell_out(0, lscpu_cores, "")) + end + + numa_node_cpus = { "0" => [0, 1] } + + it_behaves_like "Common cpu info", + "0", # default_cpu + 2, # total_cpu + 2, # real_cpu + true, # ls_cpu + "ppc64le", # architecture + nil, # cpu_opmodes + "little endian", # byte_order + 2, # cpus + 2, # cpus_online + 1, # threads_per_core + 1, # cores_per_socket + 2, # sockets + 1, # numa_nodes + nil, # vendor_id + "2.2 (pvr 004e 1202)", # model + "POWER9 (architected), altivec supported", # model_name + nil, # bogomips + "64 KiB (2 instances)", # l1d_cache + "64 KiB (2 instances)", # l1i_cache + nil, # l2_cache + nil, # l3_cache + nil, # flags + numa_node_cpus # numa_node_cpus + it_behaves_like "ppc64le processor info", + 0, # cpu_no + "POWER9 (architected), altivec supported", # model_name + "2.2 (pvr 004e 1202)", # model + "2200.000000MHz", # mhz + "512000000", # timebase + "pSeries", # platform + "IBM pSeries (emulated by qemu)", # machine_model + "CHRP IBM pSeries (emulated by qemu)", # machine + nil, # firmware + "Radix" # mmu + + it_behaves_like "virtualization info", + "para", # virtualization_type + "KVM" # hypervisor_vendor + + it "has a cpu 0" do + plugin.run + expect(plugin[:cpu]).to have_key("0") + end + end end