Shell ❀ 校验服务器CPU内存硬盘总大小脚本
Posted 无糖可乐没有灵魂
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Shell ❀ 校验服务器CPU内存硬盘总大小脚本相关的知识,希望对你有一定的参考价值。
文章目录
1 代码块
#!/bin/bash
echo "---------------------BEGIN--------------------------"
echo -e "\\033[40;31m This script queries the number of CPU cores and vendors, total memory size, and total disk size! \\033[0m"
echo "----------------------CPU--------------------------"
# CPU核数
cores=`cat /proc/cpuinfo | grep -w processor | wc -l`
vendor=`cat /proc/cpuinfo | grep vendor_id | uniq | tr -s " " | cut -d " " -f 2`
if [[ $vendor=="Genuinelnmtel" ]];then
echo "CPU is Intel!,CPU cores is $cores"
elif [[ $vendor=="AuthenticAMD" ]];then
echo "CPU is AMD!,CPU cores is $cores"
else
echo "CPU is Other!,CPU cores is $cores"
fi
echo""
echo "----------------------Mem---------------------------"
# 查看当前总内存
MemTotal=`awk -F' ' 'NR==1print$2' /proc/meminfo`
if [[ $MemTotal -ge 1024 ]];then
# 1024=MB
Mem=`echo $[MemTotal/1024]`
echo "MemTotal is $Mem MB"
elif [[ $MemTotal -ge 1048576 ]];then
# 1,048,576=GB
Mem=`echo $[MemTotal/1048576]`
echo "MemTotal is $Mem GB"
elif [[ $MemTotal -ge 1073741824 ]];then
# 1,073,741,824=TB
Mem=`echo $[MemTotal/1073741824]`
echo "MemTotal is $Mem TB"
fi
echo""
echo "----------------------DISK--------------------------"
fdisk -l | grep -E '^Disk' | grep -Ev "mapper|label|identifier|Virtual" | awk -F' ' 'print $2,$3,$4'
echo "----------------------END---------------------------"
2 执行结果
以上是关于Shell ❀ 校验服务器CPU内存硬盘总大小脚本的主要内容,如果未能解决你的问题,请参考以下文章
Java 连接远程Linux 服务器执行 shell 脚本查看 CPU内存硬盘信息