Come verificare quante CPU, Core e Thread  ha una macchina virtuale Linux

APPUNTI, LINUX, TUTORIAL

In questo articolo vi riporto alcuni metodi che possono ritornare utili qualora si volessero identificare o verificare le risorse fisiche/virtuali di una macchina linux.

Un primo modo per ottenere le informazioni di sistema è attraverso l’analisi dei log di sistema in fase di boot che possono essere analizzati lanciando il comando :

# dmesg

ad esempio lanciando il seguente comando

# dmesg | grep CPU

sarà possibile ottenere informazioni relative alla CPU, ad esempio nel mio caso il risultato è qualcosa del genere:

[    0.000000] smpboot: Allowing 8 CPUs, 0 hotplug CPUs
[    0.000000] setup_percpu: NR_CPUS:5120 nr_cpumask_bits:8 nr_cpu_ids:8 nr_node_ids:1
[    0.000000] PERCPU: Embedded 38 pages/cpu @ffff88127fc00000 s118784 r8192 d28672 u262144
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=8, Nodes=1
[    0.000000] RCU restricting CPUs from NR_CPUS=5120 to nr_cpu_ids=8.
[    0.442795] x86/cpu: Activated the Intel User Mode Instruction Prevention (UMIP) CPU feature
[    0.444051] MDS: Mitigation: Clear CPU buffers
[    0.502490] smpboot: CPU0: Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz (fam: 06, model: 4f, stepping: 01)
[    0.504954] x86/cpu: Activated the Intel User Mode Instruction Prevention (UMIP) CPU feature
[    0.506320] x86/cpu: Activated the Intel User Mode Instruction Prevention (UMIP) CPU feature
[    0.507649] x86/cpu: Activated the Intel User Mode Instruction Prevention (UMIP) CPU feature
[    0.509178] x86/cpu: Activated the Intel User Mode Instruction Prevention (UMIP) CPU feature
[    0.510535] x86/cpu: Activated the Intel User Mode Instruction Prevention (UMIP) CPU feature
[    0.511800] x86/cpu: Activated the Intel User Mode Instruction Prevention (UMIP) CPU feature
[    0.513260] x86/cpu: Activated the Intel User Mode Instruction Prevention (UMIP) CPU feature
[    0.514228] Brought up 8 CPUs

da cui si evince il tipo di CPU, il numero di core, la velocità del processore ed altre informazioni utili.

Un secondo metodo è quello di utilizzare il comando

# lscpu

il cui risultato è qualcosa del genere

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                8
On-line CPU(s) list:   0-7
Thread(s) per core:    1
Core(s) per socket:    8
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 79
Model name:            Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz
Stepping:              1
CPU MHz:               2199.998
BogoMIPS:              4399.99
Hypervisor vendor:     KVM
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              4096K
L3 cache:              16384K
NUMA node0 CPU(s):     0-7
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp 
lm constant_tsc arch_perfmon rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer 
aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid r
tm rdseed adx smap xsaveopt arat umip md_clear spec_ctrl intel_stibp arch_capabilities

oppure si può verificare  l’architettura  direttamente leggendo i proc file

come nel caso del dmseg si potrà filtrare il risultato per ottenere le informazioni di maggiore interesse ad esempio lanciando il seguente comando:

# cat /proc/cpuinfo | egrep "core id|physical id" | tr -d "\n" | sed s/physical/\\nphysical/g | grep -v ^$ | sort | uniq | wc -l

si potranno ottenere informazioni  sui Core fisici presenti sul sistema.

Un ultimo comando utile è :

# dmidecode

N.B

dmidecode è uno strumento per scaricare i contenuti della tabella DMI di un computer in un formato comprensibile. La tabella DMI contiene una descrizione dei componenti hardware del sistema, nonché altre informazioni utili come numeri di serie e revisione del BIOS. 

Se vuoi farmi qualche richiesta o contattarmi per un aiuto riempi il seguente form

    0 0 votes
    Article Rating
    Subscribe
    Notificami
    guest
    0 Commenti
    Inline Feedbacks
    View all comments
    0
    Would love your thoughts, please comment.x