Last active
August 29, 2015 14:17
-
-
Save suchasplus/090d0d904165c2b58629 to your computer and use it in GitHub Desktop.
System Check For Linux Shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
noColor="\e[0m" | |
green="\e[1;32m" | |
yellow="\e[1;33m" | |
SystemDescription=$(lsb_release -d|sed -n 's/Description:[ \t]*\([a-zA-Z]*\)/\1/p') | |
SystemMachine=$(uname -m) | |
SystemKernel=$(uname -r) | |
SystemProcessor=$(uname -p) | |
SystemCode=$(sed -n 's/.*=\(.*\)/\1/p' /etc/sinainstall.conf) | |
Date=$(date) | |
# Partitions=$(df --block-size=1G | awk '{printf ( NR < 2 ? $0"\n" : "\033[1;33m" $0 "\n\033[0m")}') # no '% | |
# Partitions=$(df --block-size=1G |sed 's/%/_percent /g' | awk '{printf ( NR < 2 ? $0"\n" : "\033[1;33m" $0 | |
Partitions=$(df --block-size=1G | grep -v none |sed 's/%/-Percent /g' | awk '{printf ( NR < 2 ? $0"\n" : "\ | |
Memory=$(free | awk '/Mem/{print $2+1}') | |
((MemoryTotal=$Memory/1000000)) | |
## MemoryTotal=$(free -g | awk '/Mem/{print $2+1}') | |
# MemoryUsed=$(free | awk '/buffers\/cache/{print $3}') | |
Swap=$(free | awk '/Swap/{print $2+1}') | |
((SwapTotal=$Swap/1000000)) | |
# SwapUsed=$(free | awk '/Swap/{print $4}') | |
DNS=$(cat /etc/resolv.conf | awk '/nameserver/{print $2}') | |
# IPInfo=$(/sbin/ifconfig | awk '/Link encap/,/inet addr/{if ($1 ~/eth./) print $1"\tMAC address "$5; if ($1 | |
# IPInfo=$(/sbin/ifconfig | awk '/eth/,/inet addr/{if ($1 ~/eth./) print $1"\tMAC address "$5;if ($1 ~/inet/ | |
# /sbin/ifconfig | awk '/eth/,/inet addr/{if ($1 ~/eth./) printf $1"\tMAC address "$5;if ($1 ~/inet/) print | |
/sbin/ifconfig | awk '/eth/,/inet/{if ($1 ~/eth./) printf $1"\tMAC address "$5;if ($1 ~/inet/) print "\t"$2" | |
# sed -n -i 's/addr:/addr /;s/Bcast:/Bcast /;s/Mask:/Mask /p' ipaddr.tmp | |
sed -i -e 's/addr:/addr /;s/Bcast:/Bcast /;s/Mask:/Mask /' ipaddr.tmp | |
IPInfo=$(awk '{print "\033[1;33m"$1"\033[0m\t"$2$3" \033[1;33m"$4"\033[0m\t"$5,"\033[1;33m"$6"\033[0m\t"$7," | |
# Mac=$(/sbin/ifconfig | sed -n '/Link encap/,/inet addr/p'| awk '/HWaddr/{print $5}') | |
RouteList=$(netstat -rn | awk '{printf ( NR < 3 ? $0"\n" : "\033[1;33m" $0 "\n\033[0m" )}') | |
#GateWay=$(netstat -rn | awk '{print $2}' | egrep -v '0.0.0.0|IP|Gateway') | |
GateWay=$(/sbin/route | awk '/default/{print $2}') | |
#PingGateWay=$( ping -f -c 100 $GateWay && echo $? ) ## fping ping -f must root privileges | |
PingGateWay=$(ping -f -c 100 $GateWay > /dev/null ; echo $?) # long time | |
GateWayAlive=$(if [ $PingGateWay ] ; then echo Alive ; else echo failed; fi) | |
PingInformationIP=$(ping -f -c 100 172.16.30.50 > /dev/null ; echo $?) # long time | |
InformationIPAlive=$(if [ $PingInformationIP ] ; then echo Alive ; else echo failed; fi) | |
ZhalangRpm=$(rpm -qa | grep -i sina) # long time | |
NICdriver=$(/sbin/modinfo bnx2 | grep 1.9.20b || dmesg | grep 1.9.20b) | |
UserAccount=$(awk -F: '/usr\/home/{printf $1" "}' /etc/passwd) | |
Siblings=$(awk '/siblings/{print $3}' /proc/cpuinfo | uniq) | |
CpuCores=$(awk '/cpu cores/{print $4}' /proc/cpuinfo | uniq) | |
HyperThreadStatus=$(if (( $Siblings > $CpuCores )) ; then echo "HyperEnable" ; else echo "HyperDisable" ; fi | |
printf "$green-----Date-----\n$noColor" | |
printf "$yellow$Date\n\n$noColor" | |
printf "$green-----System version-----\n$noColor" | |
printf "PDH $yellow $SystemCode $noColor . Operator System $yellow $SystemDescription $noColor .\nMachine $y | |
printf "$green-----Memory-----\n$noColor" | |
printf "The total Memory is $yellow ${MemoryTotal}G $noColor. The Swap is $yellow ${SwapTotal}G $noColor \n" | |
printf "$green-----Partitions-----\n$noColor" | |
printf "$Partitions\n\n" | |
printf "$green-----NetInfo-----\n$noColor" | |
printf "InterFace\n$yellow$IPInfo $noColor\n\n" | |
printf "DNS $yellow\n$DNS $noColor\n\n" | |
printf "GateWay $yellow $GateWay $noColor \n" | |
printf "GateWay is $yellow $GateWayAlive $noColor \n\n" | |
printf "InformationIP $yellow 172.16.30.50 $noColor\nInformationIP is $yellow$InformationIPAlive $noColor\n | |
printf "RouteList\n$RouteList \n" | |
printf "$green-----ZhaLang RPM-----\n$noColor" | |
printf "$yellow$SinaRpm $noColor \n" | |
printf "$green-----HyperThreadStatus-----\n$noColor" | |
printf "$yellow$HyperThreadStatus $noColor \n" | |
printf "$green-----NICdriver-----\n$noColor" | |
printf "$yellow$NICdriver $noColor \n" | |
printf "$green-----UserAccount-----\n$noColor" | |
printf "$yellow$UserAccount $noColor \n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment