简介

快速查看CPU信息脚本。

linux看cpu命令(linux-快速查看CPU信息)(1)

脚本

# CPU型号 V_CPU_MODEL=$(cat /proc/cpuinfo | grep "model name" | sort | uniq | awk -F "[:]" '{print $2}') # CPU物理核心数 V_CPU_PHY=$(cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l) # CPU核心数 # V_CPU_CORE= `cat /proc/cpuinfo | grep "cpu cores" | awk '{print $NF}' | sort | uniq` V_CPU_CORE=$(cat /proc/cpuinfo | grep "core id" | sort | uniq | wc -l) # CPU逻辑核心数 V_CPU_LOG=$(cat /proc/cpuinfo | grep "siblings" | sort | uniq | awk '{print $NF}') # 总CPU处理核心数 V_CPU_ALL=$(cat /proc/cpuinfo | grep "processor" | sort | uniq | wc -l) # 是否开启超线程 V_CPU_HYPER="" if [ $V_CPU_LOG -gt $V_CPU_CORE ]; then V_CPU_HYPER="enabled" elif [ $V_CPU_LOG -eq $V_CPU_CORE ]; then V_CPU_HYPER="disable" else V_CPU_HYPER="may be something wrong here , please checking manual !" fi # 是否开启VT V_CPU_VT="" cat /proc/cpuinfo | grep -E 'vmx|svm' >/dev/null 2>&1 && V_CPU_VT="supported" || V_CPU_VT="nonsupport" # CPU其他标记 V_CPU_FLAG_ALL=$(cat /proc/cpuinfo | grep "flags" | awk -F ':' '{print $NF}' | sort | uniq) echo -n "服务器CPU型号为:" echo "$V_CPU_MODEL" echo -n "服务器物理CPU个数为:" echo "$V_CPU_PHY" echo -n "服务器单颗物理CPU核心数:" echo "$V_CPU_CORE" echo -n "服务器单颗物理包含逻辑CPU核心数:" echo "$V_CPU_LOG" echo -n "服务器CPU核心总数:" echo "$V_CPU_ALL" echo -n "超线程启用状态:" echo "$V_CPU_HYPER" echo -n "虚拟化支持情况:" echo "$V_CPU_VT" echo -n "当前处理器全部标记:" echo "$V_CPU_FLAG_ALL" echo

,