#!/bin/bash
###系统信息####
getsys(){
#系统类型
os_type=uname
#系统版本
os_ver=cat /etc/redhat-release
#系统内核
os_ker=uname -a|awk '{print $3}'
#当前时间
os_time=date +%F_%T
#运行时间
os_run_time=uptime |awk '{print $3,$4}'|awk -F ',' '{print $1}'
#最后重启时间
os_last_reboot=who -b|awk '{print $3}'
#本机名称
os_hostname=hostname
echo “系统类型: ${os_type}”
echo “系统版本: ${os_ver}”
echo “系统内核: ${os_ker}”
echo “当前时间: ${os_time}”
echo “运行时间: ${os_run_time}”
echo “最后重启时间: ${os_last_reboot}”
echo “本机名称: ${os_hostname}”
}
###网络信息####
getnet(){
ipaddr=(ifconfig |grep -w inet|awk '{print $2}'
)
echo “本机的ip地址:${ipaddr[@]}”
#测试网络连通性
curl -I http://www.baidu.com
if [ $? -eq 0 ]; then
echo “访问网络是ok的”
else
echo “网络异常!”
fi
}
##硬件信息#####
gethardware(){
##cpu##
#cpu的数量
cpuid=grep "physical id" /proc/cpuinfo |sort |uniq |wc -l
#cpu的核心数
cpucores=grep "cores" /proc/cpuinfo |sort |uniq |awk -F ':' '{print $2}'
#cpu的型号
cpumode=grep "model