linux shell 硬體狀態檢測
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#看系統版本
versions=`cat /etc/redhat-release |awk '{print "version is:" $1"-"$4}' |awk -F '.' '{print $1"."$2}'`
#看磁碟使用情況
disks=`fdisk -l |grep "Disk" |grep -n "sectors$" |sed -e "s/:/-/g" -e "s/,//g" |awk '{print "disk is:" $2 $3 $4}'`
#看記憶體
mens=`free -h |sed -n "2p" |awk '{print "men free is:""\n" "total-"$2 "\n" "used-"$3"\n" "free-" $4}'`
#看cpu
cpus=`cat /proc/cpuinfo |grep "physical id" |sort |uniq -c|awk '{print "CPU:" "\n" $2,$NF,"\n" "Core:"$1}'`
#檢視當前操作系統平
machines=`dmidecode |grep "Product Name" |sed -ne "1p" |sed -e "s/[\t]//g"`