sys_check(){
echo "主机名称:`hostname`"
#echo "操作系统:`cat /etc/*-release|awk 'END{print}'`"
echo "操作系统:`cat /etc/*-release|awk 'END{print}'|cut -d \= -f 2|sed 's/\"//g'`"
echo "系统内核:`uname -r`"
#echo "SELinux:`/usr/sbin/sestatus | grep 'SELinux status:' | awk '{print $3}'`"
echo "系统语言:`echo $LANG |awk -F "." '{print $1}'`"
echo "系统编码:`echo $LANG |awk -F "." '{print $2}'`"
echo "当前时间:`date +%F_%T`"
echo "启动时间:`who -b | awk '{print $3,$4}'`"
echo "运行时间:`uptime | awk '{print $3 " " $4}' | sed 's/,//g'`"
}
cpu_Info(){
echo "CPU架构:`uname -m`"
echo "CPU型号:`cat /proc/cpuinfo | grep "model name" | uniq|awk -F":" '{print $2}'`"
# echo "CPU数量:`cat /proc/cpuinfo | grep "physical id"|sort|uniq|wc -l`颗"
# echo "CPU核心:`cat /proc/cpuinfo | grep "cpu cores"|sort|uniq|awk -F ":" '{print $2}'` 核"
echo "CPU线程:`cat /proc/cpuinfo | grep "processor" | awk '{print $3}'| sort | uniq | wc -l` 线程"
}
cpu_Check(){
Check_Res=`sar -u 1 5 |grep Average`
echo "CPU用户占比:`echo $Check_Res|awk '{printf $3}'`%"
echo "CPU内核占比:`echo $Check_Res|awk '{printf $5}'`%"
echo "ResCheck_CPURate:`echo $Check_Res|awk '{printf $3+$5}'`%"
echo "CPU可用占比:`echo $Check_Res|awk '{printf $8}'`%"
}
mem_check(){
free_total=`free -m | grep Mem|awk '{printf $2}'`
free_used=`free -m | grep -v Swap|awk 'END{printf $3}'`
#free_available=`free -m | grep Mem|awk '{printf $4}'`
#used_baifen=`echo "scale=2;$free_used/$free_total*100"|bc`
echo "内存合计:`free -g | awk "NR==2"| awk '{print $2}'` GB "
echo "内存used:`free -g | grep -v Swap | awk 'END{print $3}'` GB"
#echo "内存buff/cache:`free -g | awk "NR==2"| awk '{print $6}'` GB"
#echo "内存使用:`free -m | awk "NR==2"| awk '{printf ("%.2f\n", ($3+$6)/1024)}'` GB 占比 `echo "scale=2;$free_used/$free_total*100"|bc`%"
echo "ResCheck_MemRate: `echo "scale=2;($free_used/$free_total)*100"|bc`%"
# echo "内存使用:`free -mh | awk "NR==2"| awk '{print $3+$6}'` G占比 `echo "scale=2;$free_used/$free_total*100"|bc`%"
#echo "内存可用:`free -g | awk "NR==2"| awk '{print $4}'` GB 占比 `echo "scale=2;$free_available/$free_total*100"|bc`% "
#echo "内存可用:`free -g | awk "NR==2"| awk '{print $4}'` GB 占比 `echo "scale=2;$free_available/$free_total*100"|bc`% "
}
disk_Check(){
echo "`df -h | sort |grep -E "/sd|/mapper" |awk '{print "ResCheck_DiskRate:分区" $1 ," 合 计"$2" 已用" $3 " 剩余"$4 " 使用占比 " $5}'`"
# echo "`df -h | sort |grep /sd |awk '{print "ResCheck_DiskRate:分区" $1 ," 合计"$2" 已用" $3 " 剩余"$4 " 使用占比 " $5}'`"
}
ip_Addr(){
echo "`ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6 |awk -F " " 'BEGIN {count=0} {count=count+1; print "IP地址" count ":" $2}'`"
}
sys_check
cpu_Info
cpu_Check
mem_check
disk_Check
ip_Addr