技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> 系统运维 --> 快速查看服务器硬件配置信息

快速查看服务器硬件配置信息

浏览:3187次  出处信息

通过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 id' /proc/cpuinfo |sort |uniq |wc -l)
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 Size|sort |sed 's/^[ \t]*//g')
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 '\<Cached\>' |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. 配置Nginx+uwsgi更方便地部署python应用    (阅读:105405)
  2. Linux 下 PHP 5.2.x 连接 SQL Server 数据库 FreeTDS 配置笔记    (阅读:10104)
  3. nginx的配置文件    (阅读:8834)
  4. Emacs安装配置    (阅读:7310)
  5. 如何查看Linux 硬件配置信息    (阅读:5866)
  6. Centos yum 安装nginx+PHP-FPM+eAccelerator+mysql    (阅读:5615)
  7. Apache2中俩种设置PHP的异同    (阅读:5301)
  8. Linux(Ubuntu 10.04)上安装配置apache+php+mysql+phpmyadmin    (阅读:5008)
  9. 在FreeNAS/BSD搭建基于Nginx+FastCGI+MySQL+PHP的WebServer    (阅读:4758)
  10. 在Mac OS X中运行Apache + PHP + MySQL    (阅读:4366)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1