I took over two projects, suddenly the eldest brother asked me what configuration of the server, then I was ignorant, has not been too concerned about this thing, just to ensure that the server normal operation, the site can access normal, the other did not do, so today wrote a script, the configuration they want to know in this script written out. Test on your own server no bugs, if any, please come, thank you
#!/bin/bashdir= ' pwd ' Proname () { productname= ' dmidecode | grep product|sed ' s/^[ \t]*//g ' echo -e ' \033[32;49;1m [server model] \033[39; 49;0m " > $dir/conftab.txt echo -e " $productName " >> $dir/conftab.txt}sysversion () { sysversion= ' cat /etc/issue|sed -n " 1p " echo -e " \033[32;49;1m [system version] \033[39;49;0m " >> $dir/conftab.txt echo -e "$sysVersion" >> $dir/ Conftab.txt }coreversion () { coreversion= ' uname -r ' echo -e "\033[32;49;1m [kernel version] \033[39;49;0m" >> $dir/ conftab.txt echo -e "$coreVersion" >> $dir/conftab.txt} CpuInfo () { logIcalnum= ' cat /proc/cpuinfo |grep "Processor" |wc -l ' pysicalnum= ' cat /proc/cpuinfo| grep "Physical id" | sort| uniq| wc -l ' pysicalcorenum= ' cat /proc/cpuinfo| grep "Cpu cores" | uniq |awk ' {print $4} ' otherinfo= ' cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c |awk ' {print $2,$3,$7} ' firstcache= ' Cat /sys/devices/system/cpu/cpu0/cache/index0/size ' let coretotal=pysicalnum*pysicalcorenum echo -e "\033[32;49;1M [CPU Information] \033[39;49;0m " >> $dir/conftab.txt echo -e " ' getconf Long_bit ' bit, physical $coretotal core ($pysicalNum X $pysicalCoreNum), Logic $logicalnum Core, $otherInfo, first level cache $firstcache " >> $diR/conftab.txt}meminfo () { memsize= ' free -m | grep mem | awk ' {print $2} ' swapsize= ' free -m | grep swap | awk ' {print $2} ' echo -e ' \033[32;49;1m [memory information] \ 033[39;49;0m " >> $dir/conftab.txt echo -e " Memory: $memSize Mb, swap partition: $swapSize mb " >> $dir/conftab.txt}diskinfo () { diskinfo= ' fdisk -l|grep "DISK /DEV/SD" |tr "," ":" |awk -F ":" ' {print $1,$2} ' echo -e ' \033[32;49;1m [HDD info] \033[39;49;0m ' >> $dir/conftab.txt echo -e "$diskInfo" >> $dir/ Conftab.txt}netinfo () { echo -e "\033[32;49;1m [Nic information] \033[39;49;0m" >> $dir/conftab.txt for i in ' ifconfig|egrep -e "Em|eth" |grep -v interrupt| awk ' {print $1} ' do echo -e "\033[33;49;1m$i \033[39;49;0m ' ethtool $i | egrep -E " speed| Duplex " | sed " s/^[ \t]//g "|sed -re ' 1,${n;s/\n/ /} ' '" >> $dir/conftab.txt done}pronamesysversioncoreversioncpuinfomeminfodiskinfonetinfo
This article is from the "Court of the Odd Tree" blog, please be sure to keep this source http://zhangdl.blog.51cto.com/11050780/1833674
Shell One-click View Linux hardware configuration