[DISCUSSION #4: How to get and output the CPU details?]
Just thought I'd take a moment to share what what I've been trying so far. Right now I'm focusing on getting the model names so don't pay much attention to the rest of the code I've got going on. At the moment I'm using a set maximum number of supported CPUs, which is disappointing, but I still can't figure out a way to support an unlimited quantity. While it easy enough to get the number using "wc -l" to count lines from a pipe, and then assigning it to a variable, I have no idea how to proceed beyond that. Perhaps something will come to me in time...
On a side note, if you need a multi-cpu machine to test on check out Qemu. It's a virtual machine program that can emulate multiple CPUs even if your host has 1 CPU, but make sure to use kvm support or it will be excessively slow. Personally I've been testing in VMware Player, but when I need to verify the multiple CPU parts then I temporary run Qemu (with some graphics issues). The command I'm using is:
qemu-system-x86_64 -cpu qemu64 -smp 2 -enable-kvm -cdrom /home/example1/disc.iso -m 1024 -boot d
- REF: Search UUID: -q%FZOs3agVaFpClGTYdk4ieDvVCZ2Y1TNg2D79YXAt0$CbmkoiEkTimpZYq
#!/bin/bash #My Workfile Of Reveal For DISCUSSION #4: How to get and output the CPU details? #To run the script type "bash /locationofscript/reveal.sh". #COLLECTS INFO ABOUT CPUS #-Collects CPU models and makes a variable for the first 4 (still trying to figure out a way to support an unlimited number of CPUs) #--Collects the model name lines from /proc/cpuinfo raw_cpu_models=$(cat /proc/cpuinfo | grep -a "model name") #--Assigns data from line 1 to variable raw_cpu_model_1=$(echo $raw_cpu_models | head --lines=1 | tail --lines=1) #--Removes extra text and creates new variable with just the model name cpu_model_1=${raw_cpu_model_1:13} #--Assigns data from line 2 to variable raw_cpu_model_2=$(echo $raw_cpu_models | head --lines=2 | tail --lines=1) #--Removes extra text and creates new variable with just the model name cpu_model_2=${raw_cpu_model_2:13} #--Assigns data from line 3 to variable raw_cpu_model_3=$(echo $raw_cpu_models | head --lines=3 | tail --lines=1) #--Removes extra text and creates new variable with just the model name cpu_model_3=${raw_cpu_model_3:13} #--Assigns data from line 4 to variable raw_cpu_model_4=$(echo $raw_cpu_models | head --lines=4 | tail --lines=1) #--Removes extra text and creates new variable with just the model name cpu_model_4=${raw_cpu_model_4:13} #-Collects CPU architecture (this isnt done yet its just some initial code, ignore it) raw_cpu_arch_1=$(lscpu | grep -a "Architecture") cpu_arch_1=${raw_cpu_arch_1:23} #-Collects CPU rated clock rate (needs to be made CPU specfic and duplicated per CPU) raw_cpu_rcr_1=$(lscpu | grep -a "CPU MHz") cpu_rcr_1=${raw_cpu_rcr_1:23} #-Collects CPU running clock rate # #-Collects number of cores (needs to be made CPU specfic and duplicated per CPU) raw_cpu_cps_1=$(lscpu | grep -a "Core(s) per socket") cpu_cps_1=${raw_cpu_cps_1:23} #-Detects PAE support (needs to be made CPU specfic and duplicated per CPU) raw_cpu_pae_1=$(cat /proc/cpuinfo | grep -a "flags" | grep -a -o "pae") if [[ "$raw_cpu_pae_1" == "pae" ]]; then cpu_pae_1=Yes else cpu_pae_1=No fi #-Detects virtualization support # #DISPLAYS RESULTS (needs if else rules to decide how many cpu entries need to be displayed) echo System Information echo CPUs: echo "-$cpu_model_1 $cpu_rcr_1 MHz $cpu_cr_1 MHz $cpu_cps_1 core $cpu_arch_1" echo " -Supports PAE: $cpu_pae_1" echo " -Virtualization Support: $cpu_vs_1" echo "-$cpu_model_2 $cpu_rcr_2 MHz $cpu_cr_2 MHz $cpu_cps_2 core $cpu_arch_2" echo " -Supports PAE: $cpu_pae_2" echo " -Virtualization Support: $cpu_vs_2" echo "-$cpu_model_3 $cpu_rcr_3 MHz $cpu_cr_3 MHz $cpu_cps_3 core $cpu_arch_3" echo " -Supports PAE: $cpu_pae_3" echo " -Virtualization Support: $cpu_vs_3" echo "-$cpu_model_4 $cpu_rcr_4 MHz $cpu_cr_4 MHz $cpu_cps_4 core $cpu_arch_4" echo " -Supports PAE: $cpu_pae_4" echo " -Virtualization Support: $cpu_vs_4"
Edited by hollowface, 24 May 2015 - 12:55 AM.