假设我们正在运行实例,我们可以在该实例上运行什么来检测它是否x86_64
基于引力子/ARM?
我考虑过,curl -s http://169.254.169.254/latest/meta-data/...
但发现在这种情况下没有什么用。另外,可以使用实例类型(例如t4g.*
vs t3.*
)进行检测,但我希望有更直接的方法。
有没有?
答案1
快速简便的检查: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"},
...
]
}
希望有帮助:)