Amazon-Web-Services

如何從內部檢測 AWS EC2 架構?

  • August 12, 2021

假設我們正在執行實例,我們可以在該實例上執行什麼來檢測它是x86_64基於引力子還是基於 ARM 的?

我想了想,curl -s http://169.254.169.254/latest/meta-data/...但發現在這種情況下沒有任何用處。此外,可以使用實例類型(例如t4g.*vs t3.*)進行檢測,但我希望有更直接的方法。

有沒有?

快速簡便的檢查:uname -m

英特爾/AMD:

t3a.large:~ $ uname -m
x86_64

引力子/ARM:

t4g.large:~ $ uname -m
aarch64

顯示更多細節:lscpu

以 AMD CPU 為例:

t3a.large:~ $ lscpu
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   48 bits physical, 48 bits virtual
CPU(s):                          2
On-line CPU(s) list:             0,1
Thread(s) per core:              2
Core(s) per socket:              1
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       AuthenticAMD
CPU family:                      23
Model name:                      AMD EPYC 7571
CPU MHz:                         2199.880
BogoMIPS:                        4399.76
Hypervisor vendor:               KVM
Virtualization type:             full
L1d cache:                       32 KiB
L1i cache:                       64 KiB
L2 cache:                        512 KiB
L3 cache:                        8 MiB
NUMA node0 CPU(s):               0,1
...

您還可以以 JSON 格式顯示輸出,以便在腳本中使用(此處為 Graviton):

t4g.large:~ $ lscpu -J
{
  "lscpu": [
     {"field":"Architecture:", "data":"aarch64"},
     {"field":"CPU op-mode(s):", "data":"32-bit, 64-bit"},
     {"field":"Byte Order:", "data":"Little Endian"},
     {"field":"CPU(s):", "data":"2"},
     {"field":"On-line CPU(s) list:", "data":"0,1"},
     {"field":"Thread(s) per core:", "data":"1"},
     {"field":"Core(s) per socket:", "data":"2"},
     {"field":"Vendor ID:", "data":"ARM"},
     {"field":"Model name:", "data":"Neoverse-N1"},
     ...
  ]
}

希望有幫助:)

引用自:https://serverfault.com/questions/1074353