Linux 下 查看系统信息 的方法 脚本

来源:GK导航    date:2022-9-6    标签:,     admin

能够较为准确的计算出已安装硬盘容量.
不提供比较鸡肋的延迟和测速功能.

  • 使用:
bash -c "$(wget –no-check-certificate -qO- 'https://moeclub.org/attachment/LinuxShell/bench.sh')"  
  • 脚本代码:
#!/bin/bash     get_opsy() {      [ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return      [ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return      [ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return  }     next() {      printf "%-70sn" "-" | sed 's/s/-/g'  }     io_test() {      (LANG=en_US dd if=/dev/zero of=test_$$ bs=64k count=16k conv=fdatasync) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ t]*//;s/[ t]*$//'      rm -rf test_*;  }     read_Free() {      Free="0"      for addFree in `df |awk -v c=$1 '/^/dev/{print $c}'`        do           [ -n "$(echo "$addFree" |grep '[^0-9.]')" ] && echo "$addFree" && break;            Free=$( awk 'BEGIN{print '$Free' + '$addFree'}' )        done      [ $Free != '0' ] && {      for UNIT in `echo 'M G T P'`        do          Free=$( awk 'BEGIN{print '$Free' / '1024'}' )          [[ "$(echo -n "$Free" |cut -d'.' -f1)" -lt '1024' ]] && break;          [ $UNIT == 'P' ] && break;        done      echo "$Free$UNIT"      }  }         cname=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ t]*//;s/[ t]*$//' )      cores=$( awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo )      freq=$( awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ t]*//;s/[ t]*$//' )      tram=$( free -m | awk '/Mem/ {print $2}' )      swap=$( free -m | awk '/Swap/ {print $2}' )      disk=$( read_Free '2' )      fred=$( read_Free '4' )      usdp=$( read_Free '5' )      up=$( awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60;d=$1%60} {printf("%d days, %d:%d:%dn",a,b,c,d)}' /proc/uptime )      load=$( w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ t]*//;s/[ t]*$//' )      opsy=$( get_opsy )      arch=$( uname -m )      lbit=$( getconf LONG_BIT )      kern=$( uname -r )         clear      next      echo -e "tttInformation View"      next      echo "CPU model            : $cname"      echo "Number of cores      : $cores"      echo "CPU frequency        : $freq MHz"      echo "Total RAM/SWAP       : $tram MB/$swap MB"      echo "Disk capactiy        : $fred/$disk ($usdp)"      echo "System uptime        : $up"      echo "Load average         : $load"      echo "OS                   : $opsy"      echo "Arch                 : $arch ($lbit Bit)"      echo "Kernel               : $kern"  next         echo -ne "I/O speed   :"      io1=$( io_test )      echo -ne " $io1"      io2=$( io_test )      echo -ne "    $io2"      io3=$( io_test )      echo -ne "    $io3n"      ioraw1=$( echo $io1 | awk 'NR==1 {print $1}' )      [ "`echo $io1 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw1=$( awk 'BEGIN{print '$ioraw1' * 1024}' )      ioraw2=$( echo $io2 | awk 'NR==1 {print $1}' )      [ "`echo $io2 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw2=$( awk 'BEGIN{print '$ioraw2' * 1024}' )      ioraw3=$( echo $io3 | awk 'NR==1 {print $1}' )      [ "`echo $io3 | awk 'NR==1 {print $2}'`" == "GB/s" ] && ioraw3=$( awk 'BEGIN{print '$ioraw3' * 1024}' )      ioall=$( awk 'BEGIN{print '$ioraw1' + '$ioraw2' + '$ioraw3'}' )      ioavg=$( awk 'BEGIN{print '$ioall'/3}' )      echo "I/O Average : $ioavg MB/s"  next      echo      exit 0;

 

腾讯云限时秒杀【点击购买】

搬瓦工,CN2高速线路,1GB带宽,电信联通优化KVM,延迟低,速度快,建站稳定,搬瓦工BandwagonHost VPS优惠码BWH26FXH3HIQ,支持<支付宝> 【点击购买】!

Vultr$3.5日本节点,512M内存/500G流量/1G带宽,电信联通优化,延迟低,速度快【点击购买】!

阿里云香港、新加坡VPS/1核/1G/25G SSD/1T流量/30M带宽/年付¥288【点击购买】

Linux 下 查看系统信息 的方法 脚本

`微信`扫码 加好友