系统巡检脚本

#!/bin/bash
###########系统信息##########
#系统类型
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}' |awk -F ',' '{print $1}'`
#最后重启时间
os_last_reboot=`who -b |awk '{print $3}'`
#本机名称
os_hostname=`hostname`
check_url(){
for i in ${list[@]}
do
echo $i
done
}
check_url


###############网络信息###############
#######cpu########
#cpu的数量
cpuid=`grep "physical id" /proc/cpuinfo |sort |uniq |wc -l`
#cpu核心数
cpucores=`grep "cpu cores" /proc/cpuinfo |awk -F ':' '{print $2}'`
#cpu型号
cpumode=`grep "model name" /proc/cpuinfo |awk -F ':' '{print $2}'`
cpu_list=(${cpuid} ${cpucores} ${cpumode})
for i in ${cpu_list[@]}
do
echo "$i"
done


#######内存######
#内存总容量
memtotal=`free -m |grep "Mem" |awk '{print $2}'`
#剩余内存容量
memfree=`free -m |grep "Mem" |awk '{print $4}'`
mem_list=(${memtotal} ${memfree})
for i in ${mem_list[@]}
do
echo "$i"
done

原文地址:https://www.cnblogs.com/baby0123/p/11798234.html