zoukankan      html  css  js  c++  java
  • linux下获取服务器硬件信息的脚本

    这是个简单的脚本,便于查询服务器的硬件信息:

    #!/bin/bash
    #
    # Description:
    #  Used to get the hardware config information.
    #
    # History:
    #  tcpipstack, 2012/09/04, created.
    #
    
    
    #-----------------------------------------------------------------------------------------------------------------
    fn_get_cpu_info()
    {
     echo -e "
     CPU Num is: "`grep -c 'model name' /proc/cpuinfo`
     echo "`cat /proc/cpuinfo | grep processor | wc -l`"
     #echo `cat /proc/cpuinfo | grep 'model name' | sed 's'`
    }
    
    fn_get_disk_info()
    {
     echo -e "
    Disk Information: "
     for x in `df -h | grep /dev | awk '{print $5 "-" $6 "-" $2 "-" $4}' | sed 's/%//g'`
     do
      disk_status=(${x//"-"/" "})
      echo "Disk Directory ${disk_status[1]} DiskTotal=${disk_status[2]} DiskUsed=${disk_status[3]}"
     done 
    }
    
    fn_get_mem_info()
    {
     MemTotal=`free -m | grep Mem | awk '{print  $2}'`
     echo -e "
     Memory is: ${MemTotal} MB "
    }
    
    #-----------------------------------------------------------------------------------------------------------------
    echo -e "
     -----------This Computer's Hardware Config Information is: -----------
    "
    fn_get_disk_info
    fn_get_cpu_info
    fn_get_mem_info
    echo -e "
     -----------End -----------
    "

    查询结果:

  • 相关阅读:
    PHP常用函数大全
    php 数组相关的函数?
    谈谈对mvc 的认识?
    写出Zend 框架的目录结构,简单说明目录作用?
    PHP 的网站主要攻击方式有哪些?
    面试题随记
    二叉堆排序
    Mysql存储引擎
    (博客转载)创建对象的五种方式
    Java静态变量初始化的坑
  • 原文地址:https://www.cnblogs.com/30go/p/7766539.html
Copyright © 2011-2022 走看看