Automatic collection of server information (Ubuntu CentOS Pro Test)

Source: Internet
Author: User

  See annex for details.  #!/bin/bash#created by hashlinuxline= ' =========== ' #linux发行版名称if  [[ -f /usr/bin/ lsb_release ]]; then os=$ (/usr/bin/lsb_release -a |grep description |awk  -F :  ' {print $2} '  |sed  ' s/^[ \t]*//g ') else os=$ (cat /etc/issue  |sed -n  ' 1p ')  fiecho -e  "${line}\nos:\n${os}\n${line}" ######################### ############################################################################# #查看系统是否为64位: Uname -m, if present x86_ 64, then 64-bit os_version=$ (uname -m) echo -e  "Os_version:\n${os_version}\n${line}" #系统内核版本  kernel_ version=$ (uname -r)  echo -e  "Kernel_version:\n${kernel_version}\n${line}" #cpu型号CPU =$ (grep   ' model name '  /proc/cpuinfo |uniq |awk -F :  ' {print $2} '  | sed  ' s/^[ \t]*//g '  |sed  ' s/ \+/ /g ')  echo -e  "cpu model:\n${ cpu}\n${line} "#物理cpu个数Counts =$ (grep  ' Physical id '  /proc/cpuinfo |sort |uniq |wc - L) echo -e  "Total of physical cpu:\n${counts}\n${line}" #物理cpu内核数Cores =$ (grep  ' CPU  cores '  /proc/cpuinfo |uniq |awk -F :  ' {print $2} '  |sed  ' s/^ [ \t]*//g ') echo -e  "Number of cpu cores\n${cores}\n${line}" #逻辑cpu个数   processor=$ (grep  ' PROCESSOR '  /proc/cpuinfo |sort |uniq |wc -l) echo -e  "Number of logical cpus:\n${processor}\n${line}" #查看CPU当前运行模式是64位还是32位Mode =$ (getconf long_ BIT)  echo -e  "Present mode of cpu:\n${mode}\n${line}" #查看CPU是否支持64位技术:grep  ' Flags '  /proc/cpuinfo, 64-bit numbers=$ (grep  ' LM '  /proc/cpuinfo |wc -l) is supported if the LM field is included in the flags message  if  (( ${numbers} > 0));  then lm=64 else lm=32 fiecho  -e  "support&nbsp Mode of cpu:\n${lm}\n${line} "####################################################################### memtotal  Total Memory Size total=$ (cat /proc/meminfo |grep  ' memtotal '  |awk -F :  ' { print $2} '  |sed  ' s/^[ \t]*//g ') echo -e  "Total memory:\n${total}\n${line}" # System supports maximum memory  max_capacity=$ (dmidecode -t memory -q |grep  ' maximum capacity ')  |awk -F :  ' {print $2} '  |sed  ' s/^[ \t]*//g ') echo -e  "Maxinum  memory capacity:\n${max_capacity}\n${line} "#查看内存类型, frequency, number of bars, maximum memory support, etc.: Dmidecode -t memory, or dmidecode | grep -a16  "memory device$" #下面为统计内存条数Number =$ (dmidecode | grep  -A16  "memory device$"  |grep Size|sort |sed  ' s/^[ \t]*//g ' | grep  -v  ' no module installed '  | wc -l) echo -e  "number of  Physical memOry:\n${number}\n${line} "#SwapTotal  swap partition total size swaptotal=$ (cat /proc/meminfo |grep  ' Swaptotal '  |awk -F :  ' {print $2} '  |sed  ' s/^[ \t]*//g ') echo -e   "Total swap:\n${swaptotal}\n${line}" #Buffers  size buffers=$ (cat /proc/meminfo | grep  ' buffers '  |awk -F :  ' {print $2} '  |sed  ' s/^[ \t]*//g ') echo  -e  "Buffers:\n${buffers}\n${line}" #Cached  sizecached=$ (cat /proc/meminfo |grep  ' \<cached\> '  |awk -F :  ' {print $2} '  |sed  ' s/^[ \t]*//g ') echo  -e  "Cached:\n${cached}\n${line}" #空闲内存  + buffers/cacheavailable=$ (free -m |grep  - |awk -F :  ' {print $2} '  |awk  ' {print $2} ') echo -e  " Available memory:\n${available} mb\n${line} "#显示硬盘, and size  disk=$ (fdisk -l |grep  ' Disk '  |awk -f ,&nbsP; ' {print $1} '  | sed  ' s/disk identifier.*//g '  | sed  '/^$/d ') echo -e   "Amount of disks:\n${disk}\n${line}" #各挂载分区使用情况Partion =$ (df -hlp |sed -n  ' 2 , $p ') echo -e  "Usage of partions:\n${partion}\n${line}"

This article is from the "lake and Laughter" blog, please make sure to keep this source http://hashlinux.blog.51cto.com/9647696/1766993

Automatic collection of server information (Ubuntu CentOS Pro Test)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.