代码拉取完成,页面将自动刷新
#!/bin/bash
#判断cpu核心数是否小于64
cpu_number=`lscpu |grep "CPU(s):" |head -n1 |awk '{print $2}'`
if [ $cpu_number -lt 64 ];then
echo -e "\033[41m --------------------->>>>> 【cpu核心数小于64 ERROR!】 \033[0m"
else
echo -e "\033[32m --------------------->>>>> 【cpu核心数 OK!cpu_number=$cpu_number】 \033[0m"
fi
#判断cpu主频是否异常
cpu_MHz=`lscpu | grep "CPU MHz" | awk '{print $3}' | awk -F '.' '{print $1}'`
if [ $cpu_MHz -lt 1200 ]; then
echo -e "\033[41m --------------------->>>>> 【CPU主频 异常 ERROR!】 \033[0m"
else
echo -e "\033[32m --------------------->>>>> 【CPU主频 OK!】 \033[0m"
fi
##CPU socket/NUMA 校验
CPU_socket=`lscpu | grep "Socket" | awk '{print $2}'`
NUMA=`lscpu | grep "NUMA node(s)" | awk '{print $3}'`
if [ "${CPU_socket}" -eq "$NUMA" ]; then
echo -e "\033[32m --------------------->>>>> 【CPU-socket/NUMA OK!】 \033[0m"
else
echo -e "\033[41m --------------------->>>>> 【CPU-socket/NUMA ERROR!】 \033[0m"
fi
#判断根目录是否在sda
ifsda=`lsblk |grep "sda\|lvm" |grep "/$" |wc -l`
if [ $ifsda -ne 1 ];then
echo -e "\033[41m --------------------->>>>> 【系统盘不是sda ERROR!】 \033[0m"
else
echo -e "\033[32m --------------------->>>>> 【系统盘是sda OK!】 \033[0m"
fi
##判断是否有磁盘故障
dmesg | grep "Unrecovered read error" | awk '{print $4}' | sort | uniq -c | cut -d '[' -f 2 | cut -d ']' -f 1 > /tmp/a.txt
dmesg | grep 'initial error at time' | cut -d '(' -f 2 | cut -d ')' -f 1 | sort | uniq -c | awk '{print $2}' >> /tmp/a.txt
dmesg | grep "Buffer I/O error on dev" | awk '{print $7}' | sort | uniq -c | awk '{print $2}' | awk -F ',' '{print $1}' >> /tmp/a.txt
dmesg | grep "Buffer I/O error on dev" | awk '{print $8}' | sort | uniq -c | awk '{print $2}' | awk -F ',' '{print $1}' >> /tmp/a.txt
dmesg |grep -i "error" | grep -i "sd" | grep "dev[ ]sd[a-z]" |sed -r 's/(.*)(dev[ ]sd[a-z])(.*)/\2/g' |sort |uniq -c |awk '{print $3}' >>/tmp/a.txt
dmesg |grep "error (device" |awk -F")" '{print $1}' |awk '{print $NF}' |sort |uniq >>/tmp/a.txt
sed -r -i '/logical/d' /tmp/a.txt
for i in `cat /tmp/a.txt | sort | uniq -c | grep -v 'dev' |awk '{print $2}'`
do
echo -e "\033[41m --------------------->>>>> 【$i磁盘报错,确认是否换盘 ERROR!】 \033[0m"
done
rm -rf /tmp/a.txt
#判断是否有内存故障
mem_error=`dmesg |grep -i "CE memory \(scrubbing\)\|\(read\) error on" |awk '{print $10$11$12}' |sort |uniq -c |awk '{print $2}' |head -n 1 |wc -l`
men_total=`free -g |grep ^Mem |awk '{print $2}'`
if [ $mem_error -eq 0 ];then
mem_error=`dmesg |grep "Hardware Error" |wc -l`
if [ $mem_error -lt 8 ];then
echo -e "\033[32m --------------------->>>>> 【内存无报错 OK!,men_total=${men_total}GB】 \033[0m"
else
echo -e "\033[41m --------------------->>>>> 【内存报错 ERROR!,men_total=${men_total}GB】 \033[0m"
fi
else
echo -e "\033[41m --------------------->>>>> 【内存报错 ERROR!,men_total=${men_total}GB】 \033[0m"
fi
##判断内存是否为双数
all_siez=0
for i in `dmidecode | grep 'Ending Address' -B1 -A2 |grep 'Physical Array Handle' -B1 |grep "Range Size" |awk '{print $3}'`
do
let all_size+=i
done
mem_number=`dmidecode | grep 'Ending Address' -B1 -A2 |grep 'Physical Device Handle' -B1 |grep "Range Size" |awk '{print $3}' |sort |uniq -c |wc -l`
if [ $mem_number -ne 0 ];then
mem_size=`dmidecode | grep 'Ending Address' -B1 -A2 |grep 'Physical Device Handle' -B1 |grep "Range Size" |awk '{print $3}' |sort |uniq -c |awk '{print $2}'`
if [ $mem_number -eq 1 ];then
a=`expr $all_size / $mem_size`
if [ $[ $a % 2 ] != 0 ];then
echo -e "\033[41m --------------------->>>>> 【内存数量为奇数,number=$a size=${mem_size}GB all_size=${all_size}GB ERROR!】 \033[0m"
else
echo -e "\033[32m --------------------->>>>> 【内存数量为偶数 ok ,number=$a size=${mem_size}GB all_size=${all_size}GB】 \033[0m"
fi
else
echo -e "\033[41m --------------------->>>>> 【内存大小不一致 ERROR!】 \033[0m"
fi
fi
#判断是否有cpu故障
cpu_error1=`dmesg |grep -i "CMCI storm subsided: switching to interrupt mode" |head -n 1 |wc -l`
cpu_error2=`dmesg |grep -i "CMCI storm detected: switching to poll mode" |head -n 1 |wc -l`
if [ $cpu_error1 -eq 1 ] && [ $cpu_error2 -eq 1 ];then
echo -e "\033[41m --------------------->>>>> 【cpu报错 ERROR!】 \033[0m"
else
echo -e "\033[32m --------------------->>>>> 【cpu无报错 OK!】 \033[0m"
fi
#判断网卡做bond是否正确
bond_check=`ls /etc/sysconfig/network-scripts/| grep "ifcfg-bond-bond0*"|wc -l `
if [ $bond_check = 1 ];then
echo -e "\033[32m --------------------->>>>> 【bond配置 OK!】 \033[0m"
else
echo -e "\033[41m --------------------->>>>> 【bond配置有错!】 \033[0m"
fi
#判断DNS是否配置
dns_check=`cat /etc/sysconfig/network-scripts/ifcfg-bond-bond0| grep "DNS1"|wc -l `
if [ $dns_check = 1 ];then
echo -e "\033[32m --------------------->>>>> 【dns配置 OK!】 \033[0m"
else
echo -e "\033[41m --------------------->>>>> 【dns配置有误!】 \033[0m"
fi
#判断硬盘数量
hd=`lsblk |grep "^sd"|wc -l`
nv=`lsblk |grep "^nv"|wc -l`
if [ $hd = 12 ];then
echo -e "\033[32m --------------------->>>>> 【机械盘 OK!】 \033[0m"
else
echo -e "\033[41m --------------------->>>>> 【机械盘缺失 hdsl=$hd!】 \033[0m"
fi
if [ $nv = 2 ];then
echo -e "\033[32m --------------------->>>>> 【NVME盘 OK!】 \033[0m"
else
echo -e "\033[41m --------------------->>>>> 【NVME盘缺失 nvsl=$nv!】 \033[0m"
fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。