q789321 发表于 2018-8-29 06:02:52

【转】查看系统配置信息的shell脚本

  #!/bin/bash
  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')
  fi
  OS_version=$(uname -m)
  kernel_version=$(uname -r)
  CPU=$(grep 'model name' /proc/cpuinfo |uniq |awk -F : '{print $2}'|sed 's/^[ \t]*//g' |sed 's/ \+/ /g')

  Counts=$(grep 'physical>  Cores=$(grep 'cpu cores' /proc/cpuinfo |uniq |awk -F : '{print $2}' |sed 's/^[ \t]*//g')
  PROCESSOR=$(grep 'processor' /proc/cpuinfo |sort |uniq |wc -l)
  Mode=$(getconf LONG_BIT)
  Numbers=$(grep 'lm' /proc/cpuinfo |wc -l)
  if (( ${Numbers} > 0)); then lm=64
  else lm=32
  fi
  Total=$(cat /proc/meminfo |grep 'MemTotal' |awk -F : '{print $2}' |sed 's/^[ \t]*//g')

  Number=$(dmidecode | grep -A16 "Memory Device$" |grep>  SwapTotal=$(cat /proc/meminfo |grep 'SwapTotal' |awk -F : '{print $2}' |sed 's/^[ \t]*//g')
  Buffers=$(cat /proc/meminfo |grep 'Buffers' |awk -F : '{print $2}' |sed 's/^[ \t]*//g')
  Cached=$(cat /proc/meminfo |grep '\' |awk -F : '{print $2}' |sed 's/^[ \t]*//g')
  Available=$(free -m |grep - |awk -F : '{print $2}' |awk '{print $2}')
  Max_Capacity=$(dmidecode -t memory -q |grep 'Maximum Capacity' |awk -F : '{print $2}' |sed 's/^[ \t]*//g')
  Disk=$(fdisk -l |grep 'Disk' |awk -F , '{print $1}')
  Partion=$(df -hlP |sed -n '2,$p')
  Line='==========='
  echo -e "${Line}\nOS:\n${OS}\n${Line}"
  echo -e "OS_version:\n${OS_version}\n${Line}"
  echo -e "Kernel_version:\n${kernel_version}\n${Line}"
  echo -e "CPU model:\n${CPU}\n${Line}"
  echo -e "Total of physical CPU:\n${Counts}\n${Line}"
  echo -e "Number of CPU cores\n${Cores}\n${Line}"
  echo -e "Number of logical CPUs:\n${PROCESSOR}\n${Line}"
  echo -e "Present Mode Of CPU:\n${Mode}\n${Line}"
  echo -e "Support Mode Of CPU:\n${lm}\n${Line}"
  echo -e "Total Memory:\n${Total}\n${Line}"
  echo -e "Total Swap:\n${SwapTotal}\n${Line}"
  echo -e "Buffers:\n${Buffers}\n${Line}"
  echo -e "Cached:\n${Cached}\n${Line}"
  echo -e "Available Memory:\n${Available} MB\n${Line}"
  echo -e "Maxinum Memory Capacity:\n${Max_Capacity}\n${Line}"
  echo -e "Number of Physical Memory:\n${Number}\n${Line}"
  echo -e "Amount Of Disks:\n${Disk}\n${Line}"
  echo -e "Usage Of partions:\n${Partion}\n${Line}"

页: [1]
查看完整版本: 【转】查看系统配置信息的shell脚本