获取服务器 内核、CPU、内存、磁盘等信息。
kel=`uname -r`
os=`awk -F '"' '/^PRETTY_NAME/ {print $(NF-1)}' /etc/os-release`
server_info=`dmidecode -t 1 |grep -P 'Manufacturer:|Product Name:|Serial Number:'|tr -d '\t'`
memory_info=`dmidecode -t 17|tr -d '\t'|grep -P 'Size:|^Locator:|Type:|Speed:Manufacturer:|Serial Number:'`
ip=`hostname -i`
lscpu|grep -P '^CPU(|Mode Name:'
echo "主机名: $(hostname) | IP: ${ip}"
echp "CPU:"
echo "内核: ${kel} | OS: ${os}"
echo "服务器信息: ${server_info}"
echo "内存信息 ${memory_info}"
echo "磁盘信息 $(lsblk|awk '/disk/ {print $1,$4}')"